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

GetFontUnicodeRanges

関数
フォントが対応するUnicode範囲を取得する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD GetFontUnicodeRanges(
    HDC hdc,
    GLYPHSET* lpgs   // optional
);

パラメーター

名前方向
hdcHDCin
lpgsGLYPHSET*outoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetFontUnicodeRanges(
    HDC hdc,
    GLYPHSET* lpgs   // optional
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern uint GetFontUnicodeRanges(
    IntPtr hdc,   // HDC
    IntPtr lpgs   // GLYPHSET* optional, out
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function GetFontUnicodeRanges(
    hdc As IntPtr,   ' HDC
    lpgs As IntPtr   ' GLYPHSET* optional, out
) As UInteger
End Function
' hdc : HDC
' lpgs : GLYPHSET* optional, out
Declare PtrSafe Function GetFontUnicodeRanges Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal lpgs As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetFontUnicodeRanges = ctypes.windll.gdi32.GetFontUnicodeRanges
GetFontUnicodeRanges.restype = wintypes.DWORD
GetFontUnicodeRanges.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_void_p,  # lpgs : GLYPHSET* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetFontUnicodeRanges = gdi32.NewProc("GetFontUnicodeRanges")
)

// hdc (HDC), lpgs (GLYPHSET* optional, out)
r1, _, err := procGetFontUnicodeRanges.Call(
	uintptr(hdc),
	uintptr(lpgs),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetFontUnicodeRanges(
  hdc: THandle;   // HDC
  lpgs: Pointer   // GLYPHSET* optional, out
): DWORD; stdcall;
  external 'GDI32.dll' name 'GetFontUnicodeRanges';
result := DllCall("GDI32\GetFontUnicodeRanges"
    , "Ptr", hdc   ; HDC
    , "Ptr", lpgs   ; GLYPHSET* optional, out
    , "UInt")   ; return: DWORD
●GetFontUnicodeRanges(hdc, lpgs) = DLL("GDI32.dll", "dword GetFontUnicodeRanges(void*, void*)")
# 呼び出し: GetFontUnicodeRanges(hdc, lpgs)
# hdc : HDC -> "void*"
# lpgs : GLYPHSET* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。