UrlCompareW
関数2つのURLを比較し大小関係を返す。
シグネチャ
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
INT UrlCompareW(
LPCWSTR psz1,
LPCWSTR psz2,
BOOL fIgnoreSlash
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| psz1 | LPCWSTR | in |
| psz2 | LPCWSTR | in |
| fIgnoreSlash | BOOL | in |
戻り値の型: INT
各言語での呼び出し定義
// SHLWAPI.dll (Unicode / -W)
#include <windows.h>
INT UrlCompareW(
LPCWSTR psz1,
LPCWSTR psz2,
BOOL fIgnoreSlash
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int UrlCompareW(
[MarshalAs(UnmanagedType.LPWStr)] string psz1, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string psz2, // LPCWSTR
bool fIgnoreSlash // BOOL
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function UrlCompareW(
<MarshalAs(UnmanagedType.LPWStr)> psz1 As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> psz2 As String, ' LPCWSTR
fIgnoreSlash As Boolean ' BOOL
) As Integer
End Function' psz1 : LPCWSTR
' psz2 : LPCWSTR
' fIgnoreSlash : BOOL
Declare PtrSafe Function UrlCompareW Lib "shlwapi" ( _
ByVal psz1 As LongPtr, _
ByVal psz2 As LongPtr, _
ByVal fIgnoreSlash As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UrlCompareW = ctypes.windll.shlwapi.UrlCompareW
UrlCompareW.restype = ctypes.c_int
UrlCompareW.argtypes = [
wintypes.LPCWSTR, # psz1 : LPCWSTR
wintypes.LPCWSTR, # psz2 : LPCWSTR
wintypes.BOOL, # fIgnoreSlash : BOOL
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
UrlCompareW = Fiddle::Function.new(
lib['UrlCompareW'],
[
Fiddle::TYPE_VOIDP, # psz1 : LPCWSTR
Fiddle::TYPE_VOIDP, # psz2 : LPCWSTR
Fiddle::TYPE_INT, # fIgnoreSlash : BOOL
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shlwapi")]
extern "system" {
fn UrlCompareW(
psz1: *const u16, // LPCWSTR
psz2: *const u16, // LPCWSTR
fIgnoreSlash: i32 // BOOL
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Unicode)]
public static extern int UrlCompareW([MarshalAs(UnmanagedType.LPWStr)] string psz1, [MarshalAs(UnmanagedType.LPWStr)] string psz2, bool fIgnoreSlash);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_UrlCompareW' -Namespace Win32 -PassThru
# $api::UrlCompareW(psz1, psz2, fIgnoreSlash)#uselib "SHLWAPI.dll"
#func global UrlCompareW "UrlCompareW" wptr, wptr, wptr
; UrlCompareW psz1, psz2, fIgnoreSlash ; 戻り値は stat
; psz1 : LPCWSTR -> "wptr"
; psz2 : LPCWSTR -> "wptr"
; fIgnoreSlash : BOOL -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHLWAPI.dll"
#cfunc global UrlCompareW "UrlCompareW" wstr, wstr, int
; res = UrlCompareW(psz1, psz2, fIgnoreSlash)
; psz1 : LPCWSTR -> "wstr"
; psz2 : LPCWSTR -> "wstr"
; fIgnoreSlash : BOOL -> "int"; INT UrlCompareW(LPCWSTR psz1, LPCWSTR psz2, BOOL fIgnoreSlash)
#uselib "SHLWAPI.dll"
#cfunc global UrlCompareW "UrlCompareW" wstr, wstr, int
; res = UrlCompareW(psz1, psz2, fIgnoreSlash)
; psz1 : LPCWSTR -> "wstr"
; psz2 : LPCWSTR -> "wstr"
; fIgnoreSlash : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procUrlCompareW = shlwapi.NewProc("UrlCompareW")
)
// psz1 (LPCWSTR), psz2 (LPCWSTR), fIgnoreSlash (BOOL)
r1, _, err := procUrlCompareW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(psz1))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(psz2))),
uintptr(fIgnoreSlash),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction UrlCompareW(
psz1: PWideChar; // LPCWSTR
psz2: PWideChar; // LPCWSTR
fIgnoreSlash: BOOL // BOOL
): Integer; stdcall;
external 'SHLWAPI.dll' name 'UrlCompareW';result := DllCall("SHLWAPI\UrlCompareW"
, "WStr", psz1 ; LPCWSTR
, "WStr", psz2 ; LPCWSTR
, "Int", fIgnoreSlash ; BOOL
, "Int") ; return: INT●UrlCompareW(psz1, psz2, fIgnoreSlash) = DLL("SHLWAPI.dll", "int UrlCompareW(char*, char*, bool)")
# 呼び出し: UrlCompareW(psz1, psz2, fIgnoreSlash)
# psz1 : LPCWSTR -> "char*"
# psz2 : LPCWSTR -> "char*"
# fIgnoreSlash : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。