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

u_strFindFirst

関数
長さ指定で部分文字列を先頭から検索する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

WORD* u_strFindFirst(
    const WORD* s,
    INT length,
    const WORD* substring,
    INT subLength
);

パラメーター

名前方向
sWORD*in
lengthINTin
substringWORD*in
subLengthINTin

戻り値の型: WORD*

各言語での呼び出し定義

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

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

u_strFindFirst = ctypes.cdll.icuuc.u_strFindFirst
u_strFindFirst.restype = ctypes.c_void_p
u_strFindFirst.argtypes = [
    ctypes.POINTER(ctypes.c_ushort),  # s : WORD*
    ctypes.c_int,  # length : INT
    ctypes.POINTER(ctypes.c_ushort),  # substring : WORD*
    ctypes.c_int,  # subLength : INT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_strFindFirst = icuuc.NewProc("u_strFindFirst")
)

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