Win32 API 日本語リファレンス
ホームGraphics.Gdi › GetGlyphIndicesA

GetGlyphIndicesA

関数
文字列をグリフインデックスに変換して取得する。
DLLGDI32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll  (ANSI / -A)
#include <windows.h>

DWORD GetGlyphIndicesA(
    HDC hdc,
    LPCSTR lpstr,
    INT c,
    WORD* pgi,
    DWORD fl
);

パラメーター

名前方向
hdcHDCin
lpstrLPCSTRin
cINTin
pgiWORD*out
flDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

// GDI32.dll  (ANSI / -A)
#include <windows.h>

DWORD GetGlyphIndicesA(
    HDC hdc,
    LPCSTR lpstr,
    INT c,
    WORD* pgi,
    DWORD fl
);
[DllImport("GDI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint GetGlyphIndicesA(
    IntPtr hdc,   // HDC
    [MarshalAs(UnmanagedType.LPStr)] string lpstr,   // LPCSTR
    int c,   // INT
    out ushort pgi,   // WORD* out
    uint fl   // DWORD
);
<DllImport("GDI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetGlyphIndicesA(
    hdc As IntPtr,   ' HDC
    <MarshalAs(UnmanagedType.LPStr)> lpstr As String,   ' LPCSTR
    c As Integer,   ' INT
    <Out> ByRef pgi As UShort,   ' WORD* out
    fl As UInteger   ' DWORD
) As UInteger
End Function
' hdc : HDC
' lpstr : LPCSTR
' c : INT
' pgi : WORD* out
' fl : DWORD
Declare PtrSafe Function GetGlyphIndicesA Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal lpstr As String, _
    ByVal c As Long, _
    ByRef pgi As Integer, _
    ByVal fl As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetGlyphIndicesA = ctypes.windll.gdi32.GetGlyphIndicesA
GetGlyphIndicesA.restype = wintypes.DWORD
GetGlyphIndicesA.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.LPCSTR,  # lpstr : LPCSTR
    ctypes.c_int,  # c : INT
    ctypes.POINTER(ctypes.c_ushort),  # pgi : WORD* out
    wintypes.DWORD,  # fl : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
GetGlyphIndicesA = Fiddle::Function.new(
  lib['GetGlyphIndicesA'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_VOIDP,  # lpstr : LPCSTR
    Fiddle::TYPE_INT,  # c : INT
    Fiddle::TYPE_VOIDP,  # pgi : WORD* out
    -Fiddle::TYPE_INT,  # fl : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn GetGlyphIndicesA(
        hdc: *mut core::ffi::c_void,  // HDC
        lpstr: *const u8,  // LPCSTR
        c: i32,  // INT
        pgi: *mut u16,  // WORD* out
        fl: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Ansi)]
public static extern uint GetGlyphIndicesA(IntPtr hdc, [MarshalAs(UnmanagedType.LPStr)] string lpstr, int c, out ushort pgi, uint fl);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetGlyphIndicesA' -Namespace Win32 -PassThru
# $api::GetGlyphIndicesA(hdc, lpstr, c, pgi, fl)
#uselib "GDI32.dll"
#func global GetGlyphIndicesA "GetGlyphIndicesA" sptr, sptr, sptr, sptr, sptr
; GetGlyphIndicesA hdc, lpstr, c, varptr(pgi), fl   ; 戻り値は stat
; hdc : HDC -> "sptr"
; lpstr : LPCSTR -> "sptr"
; c : INT -> "sptr"
; pgi : WORD* out -> "sptr"
; fl : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global GetGlyphIndicesA "GetGlyphIndicesA" sptr, str, int, var, int
; res = GetGlyphIndicesA(hdc, lpstr, c, pgi, fl)
; hdc : HDC -> "sptr"
; lpstr : LPCSTR -> "str"
; c : INT -> "int"
; pgi : WORD* out -> "var"
; fl : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD GetGlyphIndicesA(HDC hdc, LPCSTR lpstr, INT c, WORD* pgi, DWORD fl)
#uselib "GDI32.dll"
#cfunc global GetGlyphIndicesA "GetGlyphIndicesA" intptr, str, int, var, int
; res = GetGlyphIndicesA(hdc, lpstr, c, pgi, fl)
; hdc : HDC -> "intptr"
; lpstr : LPCSTR -> "str"
; c : INT -> "int"
; pgi : WORD* out -> "var"
; fl : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetGlyphIndicesA = gdi32.NewProc("GetGlyphIndicesA")
)

// hdc (HDC), lpstr (LPCSTR), c (INT), pgi (WORD* out), fl (DWORD)
r1, _, err := procGetGlyphIndicesA.Call(
	uintptr(hdc),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpstr))),
	uintptr(c),
	uintptr(pgi),
	uintptr(fl),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetGlyphIndicesA(
  hdc: THandle;   // HDC
  lpstr: PAnsiChar;   // LPCSTR
  c: Integer;   // INT
  pgi: Pointer;   // WORD* out
  fl: DWORD   // DWORD
): DWORD; stdcall;
  external 'GDI32.dll' name 'GetGlyphIndicesA';
result := DllCall("GDI32\GetGlyphIndicesA"
    , "Ptr", hdc   ; HDC
    , "AStr", lpstr   ; LPCSTR
    , "Int", c   ; INT
    , "Ptr", pgi   ; WORD* out
    , "UInt", fl   ; DWORD
    , "UInt")   ; return: DWORD
●GetGlyphIndicesA(hdc, lpstr, c, pgi, fl) = DLL("GDI32.dll", "dword GetGlyphIndicesA(void*, char*, int, void*, dword)")
# 呼び出し: GetGlyphIndicesA(hdc, lpstr, c, pgi, fl)
# hdc : HDC -> "void*"
# lpstr : LPCSTR -> "char*"
# c : INT -> "int"
# pgi : WORD* out -> "void*"
# fl : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。