ホーム › Graphics.Gdi › GetTextFaceW
GetTextFaceW
関数現在選択中のフォントの書体名を取得する(Unicode版)。
シグネチャ
// GDI32.dll (Unicode / -W)
#include <windows.h>
INT GetTextFaceW(
HDC hdc,
INT c,
LPWSTR lpName // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| c | INT | in |
| lpName | LPWSTR | outoptional |
戻り値の型: INT
各言語での呼び出し定義
// GDI32.dll (Unicode / -W)
#include <windows.h>
INT GetTextFaceW(
HDC hdc,
INT c,
LPWSTR lpName // optional
);[DllImport("GDI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int GetTextFaceW(
IntPtr hdc, // HDC
int c, // INT
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpName // LPWSTR optional, out
);<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GetTextFaceW(
hdc As IntPtr, ' HDC
c As Integer, ' INT
<MarshalAs(UnmanagedType.LPWStr)> lpName As System.Text.StringBuilder ' LPWSTR optional, out
) As Integer
End Function' hdc : HDC
' c : INT
' lpName : LPWSTR optional, out
Declare PtrSafe Function GetTextFaceW Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByVal c As Long, _
ByVal lpName 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
GetTextFaceW = ctypes.windll.gdi32.GetTextFaceW
GetTextFaceW.restype = ctypes.c_int
GetTextFaceW.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_int, # c : INT
wintypes.LPWSTR, # lpName : LPWSTR optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
GetTextFaceW = Fiddle::Function.new(
lib['GetTextFaceW'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_INT, # c : INT
Fiddle::TYPE_VOIDP, # lpName : LPWSTR optional, out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "gdi32")]
extern "system" {
fn GetTextFaceW(
hdc: *mut core::ffi::c_void, // HDC
c: i32, // INT
lpName: *mut u16 // LPWSTR optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Unicode)]
public static extern int GetTextFaceW(IntPtr hdc, int c, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetTextFaceW' -Namespace Win32 -PassThru
# $api::GetTextFaceW(hdc, c, lpName)#uselib "GDI32.dll"
#func global GetTextFaceW "GetTextFaceW" wptr, wptr, wptr
; GetTextFaceW hdc, c, varptr(lpName) ; 戻り値は stat
; hdc : HDC -> "wptr"
; c : INT -> "wptr"
; lpName : LPWSTR optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global GetTextFaceW "GetTextFaceW" sptr, int, var ; res = GetTextFaceW(hdc, c, lpName) ; hdc : HDC -> "sptr" ; c : INT -> "int" ; lpName : LPWSTR optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global GetTextFaceW "GetTextFaceW" sptr, int, sptr ; res = GetTextFaceW(hdc, c, varptr(lpName)) ; hdc : HDC -> "sptr" ; c : INT -> "int" ; lpName : LPWSTR optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT GetTextFaceW(HDC hdc, INT c, LPWSTR lpName) #uselib "GDI32.dll" #cfunc global GetTextFaceW "GetTextFaceW" intptr, int, var ; res = GetTextFaceW(hdc, c, lpName) ; hdc : HDC -> "intptr" ; c : INT -> "int" ; lpName : LPWSTR optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT GetTextFaceW(HDC hdc, INT c, LPWSTR lpName) #uselib "GDI32.dll" #cfunc global GetTextFaceW "GetTextFaceW" intptr, int, intptr ; res = GetTextFaceW(hdc, c, varptr(lpName)) ; hdc : HDC -> "intptr" ; c : INT -> "int" ; lpName : LPWSTR optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procGetTextFaceW = gdi32.NewProc("GetTextFaceW")
)
// hdc (HDC), c (INT), lpName (LPWSTR optional, out)
r1, _, err := procGetTextFaceW.Call(
uintptr(hdc),
uintptr(c),
uintptr(lpName),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction GetTextFaceW(
hdc: THandle; // HDC
c: Integer; // INT
lpName: PWideChar // LPWSTR optional, out
): Integer; stdcall;
external 'GDI32.dll' name 'GetTextFaceW';result := DllCall("GDI32\GetTextFaceW"
, "Ptr", hdc ; HDC
, "Int", c ; INT
, "Ptr", lpName ; LPWSTR optional, out
, "Int") ; return: INT●GetTextFaceW(hdc, c, lpName) = DLL("GDI32.dll", "int GetTextFaceW(void*, int, char*)")
# 呼び出し: GetTextFaceW(hdc, c, lpName)
# hdc : HDC -> "void*"
# c : INT -> "int"
# lpName : LPWSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。