StrCmpLogicalW
関数数値を考慮した論理順で二つの文字列を比較する。
シグネチャ
// SHLWAPI.dll
#include <windows.h>
INT StrCmpLogicalW(
LPCWSTR psz1,
LPCWSTR psz2
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| psz1 | LPCWSTR | in |
| psz2 | LPCWSTR | in |
戻り値の型: INT
各言語での呼び出し定義
// SHLWAPI.dll
#include <windows.h>
INT StrCmpLogicalW(
LPCWSTR psz1,
LPCWSTR psz2
);[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern int StrCmpLogicalW(
[MarshalAs(UnmanagedType.LPWStr)] string psz1, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string psz2 // LPCWSTR
);<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function StrCmpLogicalW(
<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 StrCmpLogicalW 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
StrCmpLogicalW = ctypes.windll.shlwapi.StrCmpLogicalW
StrCmpLogicalW.restype = ctypes.c_int
StrCmpLogicalW.argtypes = [
wintypes.LPCWSTR, # psz1 : LPCWSTR
wintypes.LPCWSTR, # psz2 : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
StrCmpLogicalW = Fiddle::Function.new(
lib['StrCmpLogicalW'],
[
Fiddle::TYPE_VOIDP, # psz1 : LPCWSTR
Fiddle::TYPE_VOIDP, # psz2 : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "shlwapi")]
extern "system" {
fn StrCmpLogicalW(
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 StrCmpLogicalW([MarshalAs(UnmanagedType.LPWStr)] string psz1, [MarshalAs(UnmanagedType.LPWStr)] string psz2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_StrCmpLogicalW' -Namespace Win32 -PassThru
# $api::StrCmpLogicalW(psz1, psz2)#uselib "SHLWAPI.dll"
#func global StrCmpLogicalW "StrCmpLogicalW" sptr, sptr
; StrCmpLogicalW psz1, psz2 ; 戻り値は stat
; psz1 : LPCWSTR -> "sptr"
; psz2 : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHLWAPI.dll"
#cfunc global StrCmpLogicalW "StrCmpLogicalW" wstr, wstr
; res = StrCmpLogicalW(psz1, psz2)
; psz1 : LPCWSTR -> "wstr"
; psz2 : LPCWSTR -> "wstr"; INT StrCmpLogicalW(LPCWSTR psz1, LPCWSTR psz2)
#uselib "SHLWAPI.dll"
#cfunc global StrCmpLogicalW "StrCmpLogicalW" wstr, wstr
; res = StrCmpLogicalW(psz1, psz2)
; psz1 : LPCWSTR -> "wstr"
; psz2 : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procStrCmpLogicalW = shlwapi.NewProc("StrCmpLogicalW")
)
// psz1 (LPCWSTR), psz2 (LPCWSTR)
r1, _, err := procStrCmpLogicalW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(psz1))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(psz2))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction StrCmpLogicalW(
psz1: PWideChar; // LPCWSTR
psz2: PWideChar // LPCWSTR
): Integer; stdcall;
external 'SHLWAPI.dll' name 'StrCmpLogicalW';result := DllCall("SHLWAPI\StrCmpLogicalW"
, "WStr", psz1 ; LPCWSTR
, "WStr", psz2 ; LPCWSTR
, "Int") ; return: INT●StrCmpLogicalW(psz1, psz2) = DLL("SHLWAPI.dll", "int StrCmpLogicalW(char*, char*)")
# 呼び出し: StrCmpLogicalW(psz1, psz2)
# psz1 : LPCWSTR -> "char*"
# psz2 : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。