ホーム › Graphics.Gdi › EnumFontsW
EnumFontsW
関数デバイスで利用可能なフォントを列挙する。
シグネチャ
// GDI32.dll (Unicode / -W)
#include <windows.h>
INT EnumFontsW(
HDC hdc,
LPCWSTR lpLogfont, // optional
FONTENUMPROCW lpProc,
LPARAM lParam
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| lpLogfont | LPCWSTR | inoptional |
| lpProc | FONTENUMPROCW | in |
| lParam | LPARAM | in |
戻り値の型: INT
各言語での呼び出し定義
// GDI32.dll (Unicode / -W)
#include <windows.h>
INT EnumFontsW(
HDC hdc,
LPCWSTR lpLogfont, // optional
FONTENUMPROCW lpProc,
LPARAM lParam
);[DllImport("GDI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int EnumFontsW(
IntPtr hdc, // HDC
[MarshalAs(UnmanagedType.LPWStr)] string lpLogfont, // LPCWSTR optional
IntPtr lpProc, // FONTENUMPROCW
IntPtr lParam // LPARAM
);<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function EnumFontsW(
hdc As IntPtr, ' HDC
<MarshalAs(UnmanagedType.LPWStr)> lpLogfont As String, ' LPCWSTR optional
lpProc As IntPtr, ' FONTENUMPROCW
lParam As IntPtr ' LPARAM
) As Integer
End Function' hdc : HDC
' lpLogfont : LPCWSTR optional
' lpProc : FONTENUMPROCW
' lParam : LPARAM
Declare PtrSafe Function EnumFontsW Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByVal lpLogfont As LongPtr, _
ByVal lpProc As LongPtr, _
ByVal lParam As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EnumFontsW = ctypes.windll.gdi32.EnumFontsW
EnumFontsW.restype = ctypes.c_int
EnumFontsW.argtypes = [
wintypes.HANDLE, # hdc : HDC
wintypes.LPCWSTR, # lpLogfont : LPCWSTR optional
ctypes.c_void_p, # lpProc : FONTENUMPROCW
ctypes.c_ssize_t, # lParam : LPARAM
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
EnumFontsW = Fiddle::Function.new(
lib['EnumFontsW'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # lpLogfont : LPCWSTR optional
Fiddle::TYPE_VOIDP, # lpProc : FONTENUMPROCW
Fiddle::TYPE_INTPTR_T, # lParam : LPARAM
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "gdi32")]
extern "system" {
fn EnumFontsW(
hdc: *mut core::ffi::c_void, // HDC
lpLogfont: *const u16, // LPCWSTR optional
lpProc: *const core::ffi::c_void, // FONTENUMPROCW
lParam: isize // LPARAM
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Unicode)]
public static extern int EnumFontsW(IntPtr hdc, [MarshalAs(UnmanagedType.LPWStr)] string lpLogfont, IntPtr lpProc, IntPtr lParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_EnumFontsW' -Namespace Win32 -PassThru
# $api::EnumFontsW(hdc, lpLogfont, lpProc, lParam)#uselib "GDI32.dll"
#func global EnumFontsW "EnumFontsW" wptr, wptr, wptr, wptr
; EnumFontsW hdc, lpLogfont, lpProc, lParam ; 戻り値は stat
; hdc : HDC -> "wptr"
; lpLogfont : LPCWSTR optional -> "wptr"
; lpProc : FONTENUMPROCW -> "wptr"
; lParam : LPARAM -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "GDI32.dll"
#cfunc global EnumFontsW "EnumFontsW" sptr, wstr, sptr, sptr
; res = EnumFontsW(hdc, lpLogfont, lpProc, lParam)
; hdc : HDC -> "sptr"
; lpLogfont : LPCWSTR optional -> "wstr"
; lpProc : FONTENUMPROCW -> "sptr"
; lParam : LPARAM -> "sptr"; INT EnumFontsW(HDC hdc, LPCWSTR lpLogfont, FONTENUMPROCW lpProc, LPARAM lParam)
#uselib "GDI32.dll"
#cfunc global EnumFontsW "EnumFontsW" intptr, wstr, intptr, intptr
; res = EnumFontsW(hdc, lpLogfont, lpProc, lParam)
; hdc : HDC -> "intptr"
; lpLogfont : LPCWSTR optional -> "wstr"
; lpProc : FONTENUMPROCW -> "intptr"
; lParam : LPARAM -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procEnumFontsW = gdi32.NewProc("EnumFontsW")
)
// hdc (HDC), lpLogfont (LPCWSTR optional), lpProc (FONTENUMPROCW), lParam (LPARAM)
r1, _, err := procEnumFontsW.Call(
uintptr(hdc),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpLogfont))),
uintptr(lpProc),
uintptr(lParam),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction EnumFontsW(
hdc: THandle; // HDC
lpLogfont: PWideChar; // LPCWSTR optional
lpProc: Pointer; // FONTENUMPROCW
lParam: NativeInt // LPARAM
): Integer; stdcall;
external 'GDI32.dll' name 'EnumFontsW';result := DllCall("GDI32\EnumFontsW"
, "Ptr", hdc ; HDC
, "WStr", lpLogfont ; LPCWSTR optional
, "Ptr", lpProc ; FONTENUMPROCW
, "Ptr", lParam ; LPARAM
, "Int") ; return: INT●EnumFontsW(hdc, lpLogfont, lpProc, lParam) = DLL("GDI32.dll", "int EnumFontsW(void*, char*, void*, int)")
# 呼び出し: EnumFontsW(hdc, lpLogfont, lpProc, lParam)
# hdc : HDC -> "void*"
# lpLogfont : LPCWSTR optional -> "char*"
# lpProc : FONTENUMPROCW -> "void*"
# lParam : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。