UrlUnescapeA
関数URL中のエスケープ表記を元の文字にデコードする。
シグネチャ
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
HRESULT UrlUnescapeA(
LPSTR pszUrl,
LPSTR pszUnescaped, // optional
DWORD* pcchUnescaped, // optional
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszUrl | LPSTR | inout |
| pszUnescaped | LPSTR | outoptional |
| pcchUnescaped | DWORD* | inoutoptional |
| dwFlags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
HRESULT UrlUnescapeA(
LPSTR pszUrl,
LPSTR pszUnescaped, // optional
DWORD* pcchUnescaped, // optional
DWORD dwFlags
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int UrlUnescapeA(
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszUrl, // LPSTR in/out
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszUnescaped, // LPSTR optional, out
IntPtr pcchUnescaped, // DWORD* optional, in/out
uint dwFlags // DWORD
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function UrlUnescapeA(
<MarshalAs(UnmanagedType.LPStr)> pszUrl As System.Text.StringBuilder, ' LPSTR in/out
<MarshalAs(UnmanagedType.LPStr)> pszUnescaped As System.Text.StringBuilder, ' LPSTR optional, out
pcchUnescaped As IntPtr, ' DWORD* optional, in/out
dwFlags As UInteger ' DWORD
) As Integer
End Function' pszUrl : LPSTR in/out
' pszUnescaped : LPSTR optional, out
' pcchUnescaped : DWORD* optional, in/out
' dwFlags : DWORD
Declare PtrSafe Function UrlUnescapeA Lib "shlwapi" ( _
ByVal pszUrl As String, _
ByVal pszUnescaped As String, _
ByVal pcchUnescaped As LongPtr, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UrlUnescapeA = ctypes.windll.shlwapi.UrlUnescapeA
UrlUnescapeA.restype = ctypes.c_int
UrlUnescapeA.argtypes = [
wintypes.LPSTR, # pszUrl : LPSTR in/out
wintypes.LPSTR, # pszUnescaped : LPSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchUnescaped : DWORD* optional, in/out
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
UrlUnescapeA = Fiddle::Function.new(
lib['UrlUnescapeA'],
[
Fiddle::TYPE_VOIDP, # pszUrl : LPSTR in/out
Fiddle::TYPE_VOIDP, # pszUnescaped : LPSTR optional, out
Fiddle::TYPE_VOIDP, # pcchUnescaped : DWORD* optional, in/out
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "shlwapi")]
extern "system" {
fn UrlUnescapeA(
pszUrl: *mut u8, // LPSTR in/out
pszUnescaped: *mut u8, // LPSTR optional, out
pcchUnescaped: *mut u32, // DWORD* optional, in/out
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi)]
public static extern int UrlUnescapeA([MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszUrl, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszUnescaped, IntPtr pcchUnescaped, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_UrlUnescapeA' -Namespace Win32 -PassThru
# $api::UrlUnescapeA(pszUrl, pszUnescaped, pcchUnescaped, dwFlags)#uselib "SHLWAPI.dll"
#func global UrlUnescapeA "UrlUnescapeA" sptr, sptr, sptr, sptr
; UrlUnescapeA varptr(pszUrl), varptr(pszUnescaped), varptr(pcchUnescaped), dwFlags ; 戻り値は stat
; pszUrl : LPSTR in/out -> "sptr"
; pszUnescaped : LPSTR optional, out -> "sptr"
; pcchUnescaped : DWORD* optional, in/out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHLWAPI.dll" #cfunc global UrlUnescapeA "UrlUnescapeA" var, var, var, int ; res = UrlUnescapeA(pszUrl, pszUnescaped, pcchUnescaped, dwFlags) ; pszUrl : LPSTR in/out -> "var" ; pszUnescaped : LPSTR optional, out -> "var" ; pcchUnescaped : DWORD* optional, in/out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHLWAPI.dll" #cfunc global UrlUnescapeA "UrlUnescapeA" sptr, sptr, sptr, int ; res = UrlUnescapeA(varptr(pszUrl), varptr(pszUnescaped), varptr(pcchUnescaped), dwFlags) ; pszUrl : LPSTR in/out -> "sptr" ; pszUnescaped : LPSTR optional, out -> "sptr" ; pcchUnescaped : DWORD* optional, in/out -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT UrlUnescapeA(LPSTR pszUrl, LPSTR pszUnescaped, DWORD* pcchUnescaped, DWORD dwFlags) #uselib "SHLWAPI.dll" #cfunc global UrlUnescapeA "UrlUnescapeA" var, var, var, int ; res = UrlUnescapeA(pszUrl, pszUnescaped, pcchUnescaped, dwFlags) ; pszUrl : LPSTR in/out -> "var" ; pszUnescaped : LPSTR optional, out -> "var" ; pcchUnescaped : DWORD* optional, in/out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT UrlUnescapeA(LPSTR pszUrl, LPSTR pszUnescaped, DWORD* pcchUnescaped, DWORD dwFlags) #uselib "SHLWAPI.dll" #cfunc global UrlUnescapeA "UrlUnescapeA" intptr, intptr, intptr, int ; res = UrlUnescapeA(varptr(pszUrl), varptr(pszUnescaped), varptr(pcchUnescaped), dwFlags) ; pszUrl : LPSTR in/out -> "intptr" ; pszUnescaped : LPSTR optional, out -> "intptr" ; pcchUnescaped : DWORD* optional, in/out -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procUrlUnescapeA = shlwapi.NewProc("UrlUnescapeA")
)
// pszUrl (LPSTR in/out), pszUnescaped (LPSTR optional, out), pcchUnescaped (DWORD* optional, in/out), dwFlags (DWORD)
r1, _, err := procUrlUnescapeA.Call(
uintptr(pszUrl),
uintptr(pszUnescaped),
uintptr(pcchUnescaped),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction UrlUnescapeA(
pszUrl: PAnsiChar; // LPSTR in/out
pszUnescaped: PAnsiChar; // LPSTR optional, out
pcchUnescaped: Pointer; // DWORD* optional, in/out
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'SHLWAPI.dll' name 'UrlUnescapeA';result := DllCall("SHLWAPI\UrlUnescapeA"
, "Ptr", pszUrl ; LPSTR in/out
, "Ptr", pszUnescaped ; LPSTR optional, out
, "Ptr", pcchUnescaped ; DWORD* optional, in/out
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●UrlUnescapeA(pszUrl, pszUnescaped, pcchUnescaped, dwFlags) = DLL("SHLWAPI.dll", "int UrlUnescapeA(char*, char*, void*, dword)")
# 呼び出し: UrlUnescapeA(pszUrl, pszUnescaped, pcchUnescaped, dwFlags)
# pszUrl : LPSTR in/out -> "char*"
# pszUnescaped : LPSTR optional, out -> "char*"
# pcchUnescaped : DWORD* optional, in/out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。