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