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