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