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