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

ScriptGetGlyphABCWidth

関数
指定グリフのABC幅を取得する。
DLLUSP10.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT ScriptGetGlyphABCWidth(
    HDC hdc,
    void** psc,
    WORD wGlyph,
    ABC* pABC
);

パラメーター

名前方向
hdcHDCin
pscvoid**inout
wGlyphWORDin
pABCABC*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT ScriptGetGlyphABCWidth(
    HDC hdc,
    void** psc,
    WORD wGlyph,
    ABC* pABC
);
[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptGetGlyphABCWidth(
    IntPtr hdc,   // HDC
    IntPtr psc,   // void** in/out
    ushort wGlyph,   // WORD
    IntPtr pABC   // ABC* out
);
<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptGetGlyphABCWidth(
    hdc As IntPtr,   ' HDC
    psc As IntPtr,   ' void** in/out
    wGlyph As UShort,   ' WORD
    pABC As IntPtr   ' ABC* out
) As Integer
End Function
' hdc : HDC
' psc : void** in/out
' wGlyph : WORD
' pABC : ABC* out
Declare PtrSafe Function ScriptGetGlyphABCWidth Lib "usp10" ( _
    ByVal hdc As LongPtr, _
    ByVal psc As LongPtr, _
    ByVal wGlyph As Integer, _
    ByVal pABC As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ScriptGetGlyphABCWidth = ctypes.windll.usp10.ScriptGetGlyphABCWidth
ScriptGetGlyphABCWidth.restype = ctypes.c_int
ScriptGetGlyphABCWidth.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_void_p,  # psc : void** in/out
    ctypes.c_ushort,  # wGlyph : WORD
    ctypes.c_void_p,  # pABC : ABC* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	usp10 = windows.NewLazySystemDLL("USP10.dll")
	procScriptGetGlyphABCWidth = usp10.NewProc("ScriptGetGlyphABCWidth")
)

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