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