Win32 API 日本語リファレンス
ホームGlobalization › u_strcmp

u_strcmp

関数
二つのUChar文字列を比較する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

INT u_strcmp(
    const WORD* s1,
    const WORD* s2
);

パラメーター

名前方向
s1WORD*in
s2WORD*in

戻り値の型: INT

各言語での呼び出し定義

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

INT u_strcmp(
    const WORD* s1,
    const WORD* s2
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int u_strcmp(
    ref ushort s1,   // WORD*
    ref ushort s2   // WORD*
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_strcmp(
    ByRef s1 As UShort,   ' WORD*
    ByRef s2 As UShort   ' WORD*
) As Integer
End Function
' s1 : WORD*
' s2 : WORD*
Declare PtrSafe Function u_strcmp Lib "icuuc" ( _
    ByRef s1 As Integer, _
    ByRef s2 As Integer) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

u_strcmp = ctypes.cdll.icuuc.u_strcmp
u_strcmp.restype = ctypes.c_int
u_strcmp.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # s1 : WORD*
    ctypes.POINTER(ctypes.c_ushort),  # s2 : WORD*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
u_strcmp = Fiddle::Function.new(
  lib['u_strcmp'],
  [
    Fiddle::TYPE_VOIDP,  # s1 : WORD*
    Fiddle::TYPE_VOIDP,  # s2 : WORD*
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn u_strcmp(
        s1: *const u16,  // WORD*
        s2: *const u16  // WORD*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int u_strcmp(ref ushort s1, ref ushort s2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_strcmp' -Namespace Win32 -PassThru
# $api::u_strcmp(s1, s2)
#uselib "icuuc.dll"
#func global u_strcmp "u_strcmp" sptr, sptr
; u_strcmp varptr(s1), varptr(s2)   ; 戻り値は stat
; s1 : WORD* -> "sptr"
; s2 : WORD* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global u_strcmp "u_strcmp" var, var
; res = u_strcmp(s1, s2)
; s1 : WORD* -> "var"
; s2 : WORD* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT u_strcmp(WORD* s1, WORD* s2)
#uselib "icuuc.dll"
#cfunc global u_strcmp "u_strcmp" var, var
; res = u_strcmp(s1, s2)
; s1 : WORD* -> "var"
; s2 : WORD* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_strcmp = icuuc.NewProc("u_strcmp")
)

// s1 (WORD*), s2 (WORD*)
r1, _, err := procu_strcmp.Call(
	uintptr(s1),
	uintptr(s2),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function u_strcmp(
  s1: Pointer;   // WORD*
  s2: Pointer   // WORD*
): Integer; cdecl;
  external 'icuuc.dll' name 'u_strcmp';
result := DllCall("icuuc\u_strcmp"
    , "Ptr", s1   ; WORD*
    , "Ptr", s2   ; WORD*
    , "Cdecl Int")   ; return: INT
●u_strcmp(s1, s2) = DLL("icuuc.dll", "int u_strcmp(void*, void*)")
# 呼び出し: u_strcmp(s1, s2)
# s1 : WORD* -> "void*"
# s2 : WORD* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。