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

StrCmpIW

関数
大小文字を区別せず二つの文字列を比較する。
DLLSHLWAPI.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHLWAPI.dll
#include <windows.h>

INT StrCmpIW(
    LPCWSTR psz1,
    LPCWSTR psz2
);

パラメーター

名前方向
psz1LPCWSTRin
psz2LPCWSTRin

戻り値の型: INT

各言語での呼び出し定義

// SHLWAPI.dll
#include <windows.h>

INT StrCmpIW(
    LPCWSTR psz1,
    LPCWSTR psz2
);
[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern int StrCmpIW(
    [MarshalAs(UnmanagedType.LPWStr)] string psz1,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string psz2   // LPCWSTR
);
<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function StrCmpIW(
    <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 StrCmpIW 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

StrCmpIW = ctypes.windll.shlwapi.StrCmpIW
StrCmpIW.restype = ctypes.c_int
StrCmpIW.argtypes = [
    wintypes.LPCWSTR,  # psz1 : LPCWSTR
    wintypes.LPCWSTR,  # psz2 : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
StrCmpIW = Fiddle::Function.new(
  lib['StrCmpIW'],
  [
    Fiddle::TYPE_VOIDP,  # psz1 : LPCWSTR
    Fiddle::TYPE_VOIDP,  # psz2 : LPCWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "shlwapi")]
extern "system" {
    fn StrCmpIW(
        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 StrCmpIW([MarshalAs(UnmanagedType.LPWStr)] string psz1, [MarshalAs(UnmanagedType.LPWStr)] string psz2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_StrCmpIW' -Namespace Win32 -PassThru
# $api::StrCmpIW(psz1, psz2)
#uselib "SHLWAPI.dll"
#func global StrCmpIW "StrCmpIW" sptr, sptr
; StrCmpIW psz1, psz2   ; 戻り値は stat
; psz1 : LPCWSTR -> "sptr"
; psz2 : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHLWAPI.dll"
#cfunc global StrCmpIW "StrCmpIW" wstr, wstr
; res = StrCmpIW(psz1, psz2)
; psz1 : LPCWSTR -> "wstr"
; psz2 : LPCWSTR -> "wstr"
; INT StrCmpIW(LPCWSTR psz1, LPCWSTR psz2)
#uselib "SHLWAPI.dll"
#cfunc global StrCmpIW "StrCmpIW" wstr, wstr
; res = StrCmpIW(psz1, psz2)
; psz1 : LPCWSTR -> "wstr"
; psz2 : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procStrCmpIW = shlwapi.NewProc("StrCmpIW")
)

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