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