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

ScriptStringGetLogicalWidths

関数
解析済み文字列の各文字の論理幅を取得する。
DLLUSP10.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT ScriptStringGetLogicalWidths(
    void* ssa,
    INT* piDx
);

パラメーター

名前方向
ssavoid*in
piDxINT*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT ScriptStringGetLogicalWidths(
    void* ssa,
    INT* piDx
);
[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptStringGetLogicalWidths(
    IntPtr ssa,   // void*
    ref int piDx   // INT* in/out
);
<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptStringGetLogicalWidths(
    ssa As IntPtr,   ' void*
    ByRef piDx As Integer   ' INT* in/out
) As Integer
End Function
' ssa : void*
' piDx : INT* in/out
Declare PtrSafe Function ScriptStringGetLogicalWidths Lib "usp10" ( _
    ByVal ssa As LongPtr, _
    ByRef piDx As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ScriptStringGetLogicalWidths = ctypes.windll.usp10.ScriptStringGetLogicalWidths
ScriptStringGetLogicalWidths.restype = ctypes.c_int
ScriptStringGetLogicalWidths.argtypes = [
    ctypes.POINTER(None),  # ssa : void*
    ctypes.POINTER(ctypes.c_int),  # piDx : INT* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	usp10 = windows.NewLazySystemDLL("USP10.dll")
	procScriptStringGetLogicalWidths = usp10.NewProc("ScriptStringGetLogicalWidths")
)

// ssa (void*), piDx (INT* in/out)
r1, _, err := procScriptStringGetLogicalWidths.Call(
	uintptr(ssa),
	uintptr(piDx),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function ScriptStringGetLogicalWidths(
  ssa: Pointer;   // void*
  piDx: Pointer   // INT* in/out
): Integer; stdcall;
  external 'USP10.dll' name 'ScriptStringGetLogicalWidths';
result := DllCall("USP10\ScriptStringGetLogicalWidths"
    , "Ptr", ssa   ; void*
    , "Ptr", piDx   ; INT* in/out
    , "Int")   ; return: HRESULT
●ScriptStringGetLogicalWidths(ssa, piDx) = DLL("USP10.dll", "int ScriptStringGetLogicalWidths(void*, void*)")
# 呼び出し: ScriptStringGetLogicalWidths(ssa, piDx)
# ssa : void* -> "void*"
# piDx : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。