ホーム › Devices.WebServicesOnDevices › WSDUriEncode
WSDUriEncode
関数文字列をWSDで使用するURI形式にエンコードする。
シグネチャ
// wsdapi.dll
#include <windows.h>
HRESULT WSDUriEncode(
LPCWSTR source,
DWORD cchSource,
LPWSTR* destOut,
DWORD* cchDestOut // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| source | LPCWSTR | in |
| cchSource | DWORD | in |
| destOut | LPWSTR* | out |
| cchDestOut | DWORD* | outoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// wsdapi.dll
#include <windows.h>
HRESULT WSDUriEncode(
LPCWSTR source,
DWORD cchSource,
LPWSTR* destOut,
DWORD* cchDestOut // optional
);[DllImport("wsdapi.dll", ExactSpelling = true)]
static extern int WSDUriEncode(
[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 WSDUriEncode(
<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 WSDUriEncode 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
WSDUriEncode = ctypes.windll.wsdapi.WSDUriEncode
WSDUriEncode.restype = ctypes.c_int
WSDUriEncode.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')
WSDUriEncode = Fiddle::Function.new(
lib['WSDUriEncode'],
[
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 WSDUriEncode(
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 WSDUriEncode([MarshalAs(UnmanagedType.LPWStr)] string source, uint cchSource, IntPtr destOut, IntPtr cchDestOut);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsdapi_WSDUriEncode' -Namespace Win32 -PassThru
# $api::WSDUriEncode(source, cchSource, destOut, cchDestOut)#uselib "wsdapi.dll"
#func global WSDUriEncode "WSDUriEncode" sptr, sptr, sptr, sptr
; WSDUriEncode 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 WSDUriEncode "WSDUriEncode" wstr, int, var, var ; res = WSDUriEncode(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 WSDUriEncode "WSDUriEncode" wstr, int, sptr, sptr ; res = WSDUriEncode(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 WSDUriEncode(LPCWSTR source, DWORD cchSource, LPWSTR* destOut, DWORD* cchDestOut) #uselib "wsdapi.dll" #cfunc global WSDUriEncode "WSDUriEncode" wstr, int, var, var ; res = WSDUriEncode(source, cchSource, destOut, cchDestOut) ; source : LPCWSTR -> "wstr" ; cchSource : DWORD -> "int" ; destOut : LPWSTR* out -> "var" ; cchDestOut : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WSDUriEncode(LPCWSTR source, DWORD cchSource, LPWSTR* destOut, DWORD* cchDestOut) #uselib "wsdapi.dll" #cfunc global WSDUriEncode "WSDUriEncode" wstr, int, intptr, intptr ; res = WSDUriEncode(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")
procWSDUriEncode = wsdapi.NewProc("WSDUriEncode")
)
// source (LPCWSTR), cchSource (DWORD), destOut (LPWSTR* out), cchDestOut (DWORD* optional, out)
r1, _, err := procWSDUriEncode.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 WSDUriEncode(
source: PWideChar; // LPCWSTR
cchSource: DWORD; // DWORD
destOut: PPWideChar; // LPWSTR* out
cchDestOut: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'wsdapi.dll' name 'WSDUriEncode';result := DllCall("wsdapi\WSDUriEncode"
, "WStr", source ; LPCWSTR
, "UInt", cchSource ; DWORD
, "Ptr", destOut ; LPWSTR* out
, "Ptr", cchDestOut ; DWORD* optional, out
, "Int") ; return: HRESULT●WSDUriEncode(source, cchSource, destOut, cchDestOut) = DLL("wsdapi.dll", "int WSDUriEncode(char*, dword, void*, void*)")
# 呼び出し: WSDUriEncode(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)。