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