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

u_strlen

関数
終端ヌルまでのUChar文字列の長さを返す。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

INT u_strlen(
    const WORD* s
);

パラメーター

名前方向
sWORD*in

戻り値の型: INT

各言語での呼び出し定義

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

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

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

lib = Fiddle.dlopen('icuuc.dll')
u_strlen = Fiddle::Function.new(
  lib['u_strlen'],
  [
    Fiddle::TYPE_VOIDP,  # s : WORD*
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn u_strlen(
        s: *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_strlen(ref ushort s);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_strlen' -Namespace Win32 -PassThru
# $api::u_strlen(s)
#uselib "icuuc.dll"
#func global u_strlen "u_strlen" sptr
; u_strlen varptr(s)   ; 戻り値は stat
; s : WORD* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global u_strlen "u_strlen" var
; res = u_strlen(s)
; s : WORD* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT u_strlen(WORD* s)
#uselib "icuuc.dll"
#cfunc global u_strlen "u_strlen" var
; res = u_strlen(s)
; s : WORD* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_strlen = icuuc.NewProc("u_strlen")
)

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