Win32 API 日本語リファレンス
ホームUI.Shell › UrlCompareA

UrlCompareA

関数
2つのURLを比較し大小関係を返す。
DLLSHLWAPI.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHLWAPI.dll  (ANSI / -A)
#include <windows.h>

INT UrlCompareA(
    LPCSTR psz1,
    LPCSTR psz2,
    BOOL fIgnoreSlash
);

パラメーター

名前方向
psz1LPCSTRin
psz2LPCSTRin
fIgnoreSlashBOOLin

戻り値の型: INT

各言語での呼び出し定義

// SHLWAPI.dll  (ANSI / -A)
#include <windows.h>

INT UrlCompareA(
    LPCSTR psz1,
    LPCSTR psz2,
    BOOL fIgnoreSlash
);
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int UrlCompareA(
    [MarshalAs(UnmanagedType.LPStr)] string psz1,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string psz2,   // LPCSTR
    bool fIgnoreSlash   // BOOL
);
<DllImport("SHLWAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function UrlCompareA(
    <MarshalAs(UnmanagedType.LPStr)> psz1 As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> psz2 As String,   ' LPCSTR
    fIgnoreSlash As Boolean   ' BOOL
) As Integer
End Function
' psz1 : LPCSTR
' psz2 : LPCSTR
' fIgnoreSlash : BOOL
Declare PtrSafe Function UrlCompareA Lib "shlwapi" ( _
    ByVal psz1 As String, _
    ByVal psz2 As String, _
    ByVal fIgnoreSlash As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UrlCompareA = ctypes.windll.shlwapi.UrlCompareA
UrlCompareA.restype = ctypes.c_int
UrlCompareA.argtypes = [
    wintypes.LPCSTR,  # psz1 : LPCSTR
    wintypes.LPCSTR,  # psz2 : LPCSTR
    wintypes.BOOL,  # fIgnoreSlash : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
UrlCompareA = Fiddle::Function.new(
  lib['UrlCompareA'],
  [
    Fiddle::TYPE_VOIDP,  # psz1 : LPCSTR
    Fiddle::TYPE_VOIDP,  # psz2 : LPCSTR
    Fiddle::TYPE_INT,  # fIgnoreSlash : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "shlwapi")]
extern "system" {
    fn UrlCompareA(
        psz1: *const u8,  // LPCSTR
        psz2: *const u8,  // LPCSTR
        fIgnoreSlash: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi)]
public static extern int UrlCompareA([MarshalAs(UnmanagedType.LPStr)] string psz1, [MarshalAs(UnmanagedType.LPStr)] string psz2, bool fIgnoreSlash);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_UrlCompareA' -Namespace Win32 -PassThru
# $api::UrlCompareA(psz1, psz2, fIgnoreSlash)
#uselib "SHLWAPI.dll"
#func global UrlCompareA "UrlCompareA" sptr, sptr, sptr
; UrlCompareA psz1, psz2, fIgnoreSlash   ; 戻り値は stat
; psz1 : LPCSTR -> "sptr"
; psz2 : LPCSTR -> "sptr"
; fIgnoreSlash : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHLWAPI.dll"
#cfunc global UrlCompareA "UrlCompareA" str, str, int
; res = UrlCompareA(psz1, psz2, fIgnoreSlash)
; psz1 : LPCSTR -> "str"
; psz2 : LPCSTR -> "str"
; fIgnoreSlash : BOOL -> "int"
; INT UrlCompareA(LPCSTR psz1, LPCSTR psz2, BOOL fIgnoreSlash)
#uselib "SHLWAPI.dll"
#cfunc global UrlCompareA "UrlCompareA" str, str, int
; res = UrlCompareA(psz1, psz2, fIgnoreSlash)
; psz1 : LPCSTR -> "str"
; psz2 : LPCSTR -> "str"
; fIgnoreSlash : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procUrlCompareA = shlwapi.NewProc("UrlCompareA")
)

// psz1 (LPCSTR), psz2 (LPCSTR), fIgnoreSlash (BOOL)
r1, _, err := procUrlCompareA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(psz1))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(psz2))),
	uintptr(fIgnoreSlash),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function UrlCompareA(
  psz1: PAnsiChar;   // LPCSTR
  psz2: PAnsiChar;   // LPCSTR
  fIgnoreSlash: BOOL   // BOOL
): Integer; stdcall;
  external 'SHLWAPI.dll' name 'UrlCompareA';
result := DllCall("SHLWAPI\UrlCompareA"
    , "AStr", psz1   ; LPCSTR
    , "AStr", psz2   ; LPCSTR
    , "Int", fIgnoreSlash   ; BOOL
    , "Int")   ; return: INT
●UrlCompareA(psz1, psz2, fIgnoreSlash) = DLL("SHLWAPI.dll", "int UrlCompareA(char*, char*, bool)")
# 呼び出し: UrlCompareA(psz1, psz2, fIgnoreSlash)
# psz1 : LPCSTR -> "char*"
# psz2 : LPCSTR -> "char*"
# fIgnoreSlash : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。