ホーム › Devices.WebServicesOnDevices › WSDUriDecode
WSDUriDecode
関数URIエンコードされた文字列を元の文字列にデコードする。
シグネチャ
// wsdapi.dll
#include <windows.h>
HRESULT WSDUriDecode(
LPCWSTR source,
DWORD cchSource,
LPWSTR* destOut,
DWORD* cchDestOut // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| source | LPCWSTR | in | URIデコード対象の入力文字列。 |
| cchSource | DWORD | in | 入力文字列の文字数。0なら自動でNULL終端まで計算する。 |
| destOut | LPWSTR* | out | デコード結果文字列を受け取る出力ポインタ。 |
| cchDestOut | DWORD* | outoptional | 出力文字列の文字数を受け取る出力先。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// wsdapi.dll
#include <windows.h>
HRESULT WSDUriDecode(
LPCWSTR source,
DWORD cchSource,
LPWSTR* destOut,
DWORD* cchDestOut // optional
);[DllImport("wsdapi.dll", ExactSpelling = true)]
static extern int WSDUriDecode(
[MarshalAs(UnmanagedType.LPWStr)] string source, // LPCWSTR
uint cchSource, // DWORD
IntPtr destOut, // LPWSTR* out
IntPtr cchDestOut // DWORD* optional, out
);<DllImport("wsdapi.dll", ExactSpelling:=True)>
Public Shared Function WSDUriDecode(
<MarshalAs(UnmanagedType.LPWStr)> source As String, ' LPCWSTR
cchSource As UInteger, ' DWORD
destOut As IntPtr, ' LPWSTR* out
cchDestOut As IntPtr ' DWORD* optional, out
) As Integer
End Function' source : LPCWSTR
' cchSource : DWORD
' destOut : LPWSTR* out
' cchDestOut : DWORD* optional, out
Declare PtrSafe Function WSDUriDecode Lib "wsdapi" ( _
ByVal source As LongPtr, _
ByVal cchSource As Long, _
ByVal destOut As LongPtr, _
ByVal cchDestOut As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WSDUriDecode = ctypes.windll.wsdapi.WSDUriDecode
WSDUriDecode.restype = ctypes.c_int
WSDUriDecode.argtypes = [
wintypes.LPCWSTR, # source : LPCWSTR
wintypes.DWORD, # cchSource : DWORD
ctypes.c_void_p, # destOut : LPWSTR* out
ctypes.POINTER(wintypes.DWORD), # cchDestOut : DWORD* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wsdapi.dll')
WSDUriDecode = Fiddle::Function.new(
lib['WSDUriDecode'],
[
Fiddle::TYPE_VOIDP, # source : LPCWSTR
-Fiddle::TYPE_INT, # cchSource : DWORD
Fiddle::TYPE_VOIDP, # destOut : LPWSTR* out
Fiddle::TYPE_VOIDP, # cchDestOut : DWORD* optional, out
],
Fiddle::TYPE_INT)#[link(name = "wsdapi")]
extern "system" {
fn WSDUriDecode(
source: *const u16, // LPCWSTR
cchSource: u32, // DWORD
destOut: *mut *mut u16, // LPWSTR* out
cchDestOut: *mut u32 // DWORD* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wsdapi.dll")]
public static extern int WSDUriDecode([MarshalAs(UnmanagedType.LPWStr)] string source, uint cchSource, IntPtr destOut, IntPtr cchDestOut);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsdapi_WSDUriDecode' -Namespace Win32 -PassThru
# $api::WSDUriDecode(source, cchSource, destOut, cchDestOut)#uselib "wsdapi.dll"
#func global WSDUriDecode "WSDUriDecode" sptr, sptr, sptr, sptr
; WSDUriDecode source, cchSource, varptr(destOut), varptr(cchDestOut) ; 戻り値は stat
; source : LPCWSTR -> "sptr"
; cchSource : DWORD -> "sptr"
; destOut : LPWSTR* out -> "sptr"
; cchDestOut : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "wsdapi.dll" #cfunc global WSDUriDecode "WSDUriDecode" wstr, int, var, var ; res = WSDUriDecode(source, cchSource, destOut, cchDestOut) ; source : LPCWSTR -> "wstr" ; cchSource : DWORD -> "int" ; destOut : LPWSTR* out -> "var" ; cchDestOut : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "wsdapi.dll" #cfunc global WSDUriDecode "WSDUriDecode" wstr, int, sptr, sptr ; res = WSDUriDecode(source, cchSource, varptr(destOut), varptr(cchDestOut)) ; source : LPCWSTR -> "wstr" ; cchSource : DWORD -> "int" ; destOut : LPWSTR* out -> "sptr" ; cchDestOut : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WSDUriDecode(LPCWSTR source, DWORD cchSource, LPWSTR* destOut, DWORD* cchDestOut) #uselib "wsdapi.dll" #cfunc global WSDUriDecode "WSDUriDecode" wstr, int, var, var ; res = WSDUriDecode(source, cchSource, destOut, cchDestOut) ; source : LPCWSTR -> "wstr" ; cchSource : DWORD -> "int" ; destOut : LPWSTR* out -> "var" ; cchDestOut : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WSDUriDecode(LPCWSTR source, DWORD cchSource, LPWSTR* destOut, DWORD* cchDestOut) #uselib "wsdapi.dll" #cfunc global WSDUriDecode "WSDUriDecode" wstr, int, intptr, intptr ; res = WSDUriDecode(source, cchSource, varptr(destOut), varptr(cchDestOut)) ; source : LPCWSTR -> "wstr" ; cchSource : DWORD -> "int" ; destOut : LPWSTR* out -> "intptr" ; cchDestOut : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsdapi = windows.NewLazySystemDLL("wsdapi.dll")
procWSDUriDecode = wsdapi.NewProc("WSDUriDecode")
)
// source (LPCWSTR), cchSource (DWORD), destOut (LPWSTR* out), cchDestOut (DWORD* optional, out)
r1, _, err := procWSDUriDecode.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(source))),
uintptr(cchSource),
uintptr(destOut),
uintptr(cchDestOut),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WSDUriDecode(
source: PWideChar; // LPCWSTR
cchSource: DWORD; // DWORD
destOut: PPWideChar; // LPWSTR* out
cchDestOut: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'wsdapi.dll' name 'WSDUriDecode';result := DllCall("wsdapi\WSDUriDecode"
, "WStr", source ; LPCWSTR
, "UInt", cchSource ; DWORD
, "Ptr", destOut ; LPWSTR* out
, "Ptr", cchDestOut ; DWORD* optional, out
, "Int") ; return: HRESULT●WSDUriDecode(source, cchSource, destOut, cchDestOut) = DLL("wsdapi.dll", "int WSDUriDecode(char*, dword, void*, void*)")
# 呼び出し: WSDUriDecode(source, cchSource, destOut, cchDestOut)
# source : LPCWSTR -> "char*"
# cchSource : DWORD -> "dword"
# destOut : LPWSTR* out -> "void*"
# cchDestOut : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wsdapi" fn WSDUriDecode(
source: [*c]const u16, // LPCWSTR
cchSource: u32, // DWORD
destOut: [*c][*c]u16, // LPWSTR* out
cchDestOut: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;proc WSDUriDecode(
source: WideCString, # LPCWSTR
cchSource: uint32, # DWORD
destOut: ptr WideCString, # LPWSTR* out
cchDestOut: ptr uint32 # DWORD* optional, out
): int32 {.importc: "WSDUriDecode", stdcall, dynlib: "wsdapi.dll".}pragma(lib, "wsdapi");
extern(Windows)
int WSDUriDecode(
const(wchar)* source, // LPCWSTR
uint cchSource, // DWORD
wchar** destOut, // LPWSTR* out
uint* cchDestOut // DWORD* optional, out
);ccall((:WSDUriDecode, "wsdapi.dll"), stdcall, Int32,
(Cwstring, UInt32, Ptr{Ptr{UInt16}}, Ptr{UInt32}),
source, cchSource, destOut, cchDestOut)
# source : LPCWSTR -> Cwstring
# cchSource : DWORD -> UInt32
# destOut : LPWSTR* out -> Ptr{Ptr{UInt16}}
# cchDestOut : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WSDUriDecode(
const uint16_t* source,
uint32_t cchSource,
uint16_t** destOut,
uint32_t* cchDestOut);
]]
local wsdapi = ffi.load("wsdapi")
-- wsdapi.WSDUriDecode(source, cchSource, destOut, cchDestOut)
-- source : LPCWSTR
-- cchSource : DWORD
-- destOut : LPWSTR* out
-- cchDestOut : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wsdapi.dll');
const WSDUriDecode = lib.func('__stdcall', 'WSDUriDecode', 'int32_t', ['str16', 'uint32_t', 'void *', 'uint32_t *']);
// WSDUriDecode(source, cchSource, destOut, cchDestOut)
// source : LPCWSTR -> 'str16'
// cchSource : DWORD -> 'uint32_t'
// destOut : LPWSTR* out -> 'void *'
// cchDestOut : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wsdapi.dll", {
WSDUriDecode: { parameters: ["buffer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WSDUriDecode(source, cchSource, destOut, cchDestOut)
// source : LPCWSTR -> "buffer"
// cchSource : DWORD -> "u32"
// destOut : LPWSTR* out -> "pointer"
// cchDestOut : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WSDUriDecode(
const uint16_t* source,
uint32_t cchSource,
uint16_t** destOut,
uint32_t* cchDestOut);
C, "wsdapi.dll");
// $ffi->WSDUriDecode(source, cchSource, destOut, cchDestOut);
// source : LPCWSTR
// cchSource : DWORD
// destOut : LPWSTR* out
// cchDestOut : DWORD* optional, out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wsdapi extends StdCallLibrary {
Wsdapi INSTANCE = Native.load("wsdapi", Wsdapi.class);
int WSDUriDecode(
WString source, // LPCWSTR
int cchSource, // DWORD
PointerByReference destOut, // LPWSTR* out
IntByReference cchDestOut // DWORD* optional, out
);
}@[Link("wsdapi")]
lib Libwsdapi
fun WSDUriDecode = WSDUriDecode(
source : UInt16*, # LPCWSTR
cchSource : UInt32, # DWORD
destOut : UInt16**, # LPWSTR* out
cchDestOut : UInt32* # DWORD* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WSDUriDecodeNative = Int32 Function(Pointer<Utf16>, Uint32, Pointer<Pointer<Utf16>>, Pointer<Uint32>);
typedef WSDUriDecodeDart = int Function(Pointer<Utf16>, int, Pointer<Pointer<Utf16>>, Pointer<Uint32>);
final WSDUriDecode = DynamicLibrary.open('wsdapi.dll')
.lookupFunction<WSDUriDecodeNative, WSDUriDecodeDart>('WSDUriDecode');
// source : LPCWSTR -> Pointer<Utf16>
// cchSource : DWORD -> Uint32
// destOut : LPWSTR* out -> Pointer<Pointer<Utf16>>
// cchDestOut : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WSDUriDecode(
source: PWideChar; // LPCWSTR
cchSource: DWORD; // DWORD
destOut: PPWideChar; // LPWSTR* out
cchDestOut: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'wsdapi.dll' name 'WSDUriDecode';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WSDUriDecode"
c_WSDUriDecode :: CWString -> Word32 -> Ptr CWString -> Ptr Word32 -> IO Int32
-- source : LPCWSTR -> CWString
-- cchSource : DWORD -> Word32
-- destOut : LPWSTR* out -> Ptr CWString
-- cchDestOut : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsduridecode =
foreign "WSDUriDecode"
((ptr uint16_t) @-> uint32_t @-> (ptr (ptr uint16_t)) @-> (ptr uint32_t) @-> returning int32_t)
(* source : LPCWSTR -> (ptr uint16_t) *)
(* cchSource : DWORD -> uint32_t *)
(* destOut : LPWSTR* out -> (ptr (ptr uint16_t)) *)
(* cchDestOut : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wsdapi (t "wsdapi.dll"))
(cffi:use-foreign-library wsdapi)
(cffi:defcfun ("WSDUriDecode" wsduri-decode :convention :stdcall) :int32
(source (:string :encoding :utf-16le)) ; LPCWSTR
(cch-source :uint32) ; DWORD
(dest-out :pointer) ; LPWSTR* out
(cch-dest-out :pointer)) ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WSDUriDecode = Win32::API::More->new('wsdapi',
'int WSDUriDecode(LPCWSTR source, DWORD cchSource, LPVOID destOut, LPVOID cchDestOut)');
# my $ret = $WSDUriDecode->Call($source, $cchSource, $destOut, $cchDestOut);
# source : LPCWSTR -> LPCWSTR
# cchSource : DWORD -> DWORD
# destOut : LPWSTR* out -> LPVOID
# cchDestOut : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。