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

ScriptItemize

関数
文字列をスクリプト単位のアイテムに分割する。
DLLUSP10.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT ScriptItemize(
    LPCWSTR pwcInChars,
    INT cInChars,
    INT cMaxItems,
    const SCRIPT_CONTROL* psControl,   // optional
    const SCRIPT_STATE* psState,   // optional
    SCRIPT_ITEM* pItems,
    INT* pcItems
);

パラメーター

名前方向
pwcInCharsLPCWSTRin
cInCharsINTin
cMaxItemsINTin
psControlSCRIPT_CONTROL*inoptional
psStateSCRIPT_STATE*inoptional
pItemsSCRIPT_ITEM*out
pcItemsINT*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT ScriptItemize(
    LPCWSTR pwcInChars,
    INT cInChars,
    INT cMaxItems,
    const SCRIPT_CONTROL* psControl,   // optional
    const SCRIPT_STATE* psState,   // optional
    SCRIPT_ITEM* pItems,
    INT* pcItems
);
[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptItemize(
    [MarshalAs(UnmanagedType.LPWStr)] string pwcInChars,   // LPCWSTR
    int cInChars,   // INT
    int cMaxItems,   // INT
    IntPtr psControl,   // SCRIPT_CONTROL* optional
    IntPtr psState,   // SCRIPT_STATE* optional
    IntPtr pItems,   // SCRIPT_ITEM* out
    out int pcItems   // INT* out
);
<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptItemize(
    <MarshalAs(UnmanagedType.LPWStr)> pwcInChars As String,   ' LPCWSTR
    cInChars As Integer,   ' INT
    cMaxItems As Integer,   ' INT
    psControl As IntPtr,   ' SCRIPT_CONTROL* optional
    psState As IntPtr,   ' SCRIPT_STATE* optional
    pItems As IntPtr,   ' SCRIPT_ITEM* out
    <Out> ByRef pcItems As Integer   ' INT* out
) As Integer
End Function
' pwcInChars : LPCWSTR
' cInChars : INT
' cMaxItems : INT
' psControl : SCRIPT_CONTROL* optional
' psState : SCRIPT_STATE* optional
' pItems : SCRIPT_ITEM* out
' pcItems : INT* out
Declare PtrSafe Function ScriptItemize Lib "usp10" ( _
    ByVal pwcInChars As LongPtr, _
    ByVal cInChars As Long, _
    ByVal cMaxItems As Long, _
    ByVal psControl As LongPtr, _
    ByVal psState As LongPtr, _
    ByVal pItems As LongPtr, _
    ByRef pcItems As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ScriptItemize = ctypes.windll.usp10.ScriptItemize
ScriptItemize.restype = ctypes.c_int
ScriptItemize.argtypes = [
    wintypes.LPCWSTR,  # pwcInChars : LPCWSTR
    ctypes.c_int,  # cInChars : INT
    ctypes.c_int,  # cMaxItems : INT
    ctypes.c_void_p,  # psControl : SCRIPT_CONTROL* optional
    ctypes.c_void_p,  # psState : SCRIPT_STATE* optional
    ctypes.c_void_p,  # pItems : SCRIPT_ITEM* out
    ctypes.POINTER(ctypes.c_int),  # pcItems : INT* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USP10.dll')
ScriptItemize = Fiddle::Function.new(
  lib['ScriptItemize'],
  [
    Fiddle::TYPE_VOIDP,  # pwcInChars : LPCWSTR
    Fiddle::TYPE_INT,  # cInChars : INT
    Fiddle::TYPE_INT,  # cMaxItems : INT
    Fiddle::TYPE_VOIDP,  # psControl : SCRIPT_CONTROL* optional
    Fiddle::TYPE_VOIDP,  # psState : SCRIPT_STATE* optional
    Fiddle::TYPE_VOIDP,  # pItems : SCRIPT_ITEM* out
    Fiddle::TYPE_VOIDP,  # pcItems : INT* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "usp10")]
extern "system" {
    fn ScriptItemize(
        pwcInChars: *const u16,  // LPCWSTR
        cInChars: i32,  // INT
        cMaxItems: i32,  // INT
        psControl: *const SCRIPT_CONTROL,  // SCRIPT_CONTROL* optional
        psState: *const SCRIPT_STATE,  // SCRIPT_STATE* optional
        pItems: *mut SCRIPT_ITEM,  // SCRIPT_ITEM* out
        pcItems: *mut i32  // INT* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USP10.dll")]
public static extern int ScriptItemize([MarshalAs(UnmanagedType.LPWStr)] string pwcInChars, int cInChars, int cMaxItems, IntPtr psControl, IntPtr psState, IntPtr pItems, out int pcItems);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptItemize' -Namespace Win32 -PassThru
# $api::ScriptItemize(pwcInChars, cInChars, cMaxItems, psControl, psState, pItems, pcItems)
#uselib "USP10.dll"
#func global ScriptItemize "ScriptItemize" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ScriptItemize pwcInChars, cInChars, cMaxItems, varptr(psControl), varptr(psState), varptr(pItems), varptr(pcItems)   ; 戻り値は stat
; pwcInChars : LPCWSTR -> "sptr"
; cInChars : INT -> "sptr"
; cMaxItems : INT -> "sptr"
; psControl : SCRIPT_CONTROL* optional -> "sptr"
; psState : SCRIPT_STATE* optional -> "sptr"
; pItems : SCRIPT_ITEM* out -> "sptr"
; pcItems : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USP10.dll"
#cfunc global ScriptItemize "ScriptItemize" wstr, int, int, var, var, var, var
; res = ScriptItemize(pwcInChars, cInChars, cMaxItems, psControl, psState, pItems, pcItems)
; pwcInChars : LPCWSTR -> "wstr"
; cInChars : INT -> "int"
; cMaxItems : INT -> "int"
; psControl : SCRIPT_CONTROL* optional -> "var"
; psState : SCRIPT_STATE* optional -> "var"
; pItems : SCRIPT_ITEM* out -> "var"
; pcItems : INT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT ScriptItemize(LPCWSTR pwcInChars, INT cInChars, INT cMaxItems, SCRIPT_CONTROL* psControl, SCRIPT_STATE* psState, SCRIPT_ITEM* pItems, INT* pcItems)
#uselib "USP10.dll"
#cfunc global ScriptItemize "ScriptItemize" wstr, int, int, var, var, var, var
; res = ScriptItemize(pwcInChars, cInChars, cMaxItems, psControl, psState, pItems, pcItems)
; pwcInChars : LPCWSTR -> "wstr"
; cInChars : INT -> "int"
; cMaxItems : INT -> "int"
; psControl : SCRIPT_CONTROL* optional -> "var"
; psState : SCRIPT_STATE* optional -> "var"
; pItems : SCRIPT_ITEM* out -> "var"
; pcItems : INT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	usp10 = windows.NewLazySystemDLL("USP10.dll")
	procScriptItemize = usp10.NewProc("ScriptItemize")
)

// pwcInChars (LPCWSTR), cInChars (INT), cMaxItems (INT), psControl (SCRIPT_CONTROL* optional), psState (SCRIPT_STATE* optional), pItems (SCRIPT_ITEM* out), pcItems (INT* out)
r1, _, err := procScriptItemize.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwcInChars))),
	uintptr(cInChars),
	uintptr(cMaxItems),
	uintptr(psControl),
	uintptr(psState),
	uintptr(pItems),
	uintptr(pcItems),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function ScriptItemize(
  pwcInChars: PWideChar;   // LPCWSTR
  cInChars: Integer;   // INT
  cMaxItems: Integer;   // INT
  psControl: Pointer;   // SCRIPT_CONTROL* optional
  psState: Pointer;   // SCRIPT_STATE* optional
  pItems: Pointer;   // SCRIPT_ITEM* out
  pcItems: Pointer   // INT* out
): Integer; stdcall;
  external 'USP10.dll' name 'ScriptItemize';
result := DllCall("USP10\ScriptItemize"
    , "WStr", pwcInChars   ; LPCWSTR
    , "Int", cInChars   ; INT
    , "Int", cMaxItems   ; INT
    , "Ptr", psControl   ; SCRIPT_CONTROL* optional
    , "Ptr", psState   ; SCRIPT_STATE* optional
    , "Ptr", pItems   ; SCRIPT_ITEM* out
    , "Ptr", pcItems   ; INT* out
    , "Int")   ; return: HRESULT
●ScriptItemize(pwcInChars, cInChars, cMaxItems, psControl, psState, pItems, pcItems) = DLL("USP10.dll", "int ScriptItemize(char*, int, int, void*, void*, void*, void*)")
# 呼び出し: ScriptItemize(pwcInChars, cInChars, cMaxItems, psControl, psState, pItems, pcItems)
# pwcInChars : LPCWSTR -> "char*"
# cInChars : INT -> "int"
# cMaxItems : INT -> "int"
# psControl : SCRIPT_CONTROL* optional -> "void*"
# psState : SCRIPT_STATE* optional -> "void*"
# pItems : SCRIPT_ITEM* out -> "void*"
# pcItems : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。