Win32 API 日本語リファレンス
ホームSystem.Console › GetCurrentConsoleFontEx

GetCurrentConsoleFontEx

関数
コンソールで現在使用中のフォントの拡張情報を取得する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり

シグネチャ

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

BOOL GetCurrentConsoleFontEx(
    HANDLE hConsoleOutput,
    BOOL bMaximumWindow,
    CONSOLE_FONT_INFOEX* lpConsoleCurrentFontEx
);

パラメーター

名前方向
hConsoleOutputHANDLEin
bMaximumWindowBOOLin
lpConsoleCurrentFontExCONSOLE_FONT_INFOEX*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetCurrentConsoleFontEx(
    HANDLE hConsoleOutput,
    BOOL bMaximumWindow,
    CONSOLE_FONT_INFOEX* lpConsoleCurrentFontEx
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetCurrentConsoleFontEx(
    IntPtr hConsoleOutput,   // HANDLE
    bool bMaximumWindow,   // BOOL
    IntPtr lpConsoleCurrentFontEx   // CONSOLE_FONT_INFOEX* out
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetCurrentConsoleFontEx(
    hConsoleOutput As IntPtr,   ' HANDLE
    bMaximumWindow As Boolean,   ' BOOL
    lpConsoleCurrentFontEx As IntPtr   ' CONSOLE_FONT_INFOEX* out
) As Boolean
End Function
' hConsoleOutput : HANDLE
' bMaximumWindow : BOOL
' lpConsoleCurrentFontEx : CONSOLE_FONT_INFOEX* out
Declare PtrSafe Function GetCurrentConsoleFontEx Lib "kernel32" ( _
    ByVal hConsoleOutput As LongPtr, _
    ByVal bMaximumWindow As Long, _
    ByVal lpConsoleCurrentFontEx As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetCurrentConsoleFontEx = ctypes.windll.kernel32.GetCurrentConsoleFontEx
GetCurrentConsoleFontEx.restype = wintypes.BOOL
GetCurrentConsoleFontEx.argtypes = [
    wintypes.HANDLE,  # hConsoleOutput : HANDLE
    wintypes.BOOL,  # bMaximumWindow : BOOL
    ctypes.c_void_p,  # lpConsoleCurrentFontEx : CONSOLE_FONT_INFOEX* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
GetCurrentConsoleFontEx = Fiddle::Function.new(
  lib['GetCurrentConsoleFontEx'],
  [
    Fiddle::TYPE_VOIDP,  # hConsoleOutput : HANDLE
    Fiddle::TYPE_INT,  # bMaximumWindow : BOOL
    Fiddle::TYPE_VOIDP,  # lpConsoleCurrentFontEx : CONSOLE_FONT_INFOEX* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn GetCurrentConsoleFontEx(
        hConsoleOutput: *mut core::ffi::c_void,  // HANDLE
        bMaximumWindow: i32,  // BOOL
        lpConsoleCurrentFontEx: *mut CONSOLE_FONT_INFOEX  // CONSOLE_FONT_INFOEX* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool GetCurrentConsoleFontEx(IntPtr hConsoleOutput, bool bMaximumWindow, IntPtr lpConsoleCurrentFontEx);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetCurrentConsoleFontEx' -Namespace Win32 -PassThru
# $api::GetCurrentConsoleFontEx(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFontEx)
#uselib "KERNEL32.dll"
#func global GetCurrentConsoleFontEx "GetCurrentConsoleFontEx" sptr, sptr, sptr
; GetCurrentConsoleFontEx hConsoleOutput, bMaximumWindow, varptr(lpConsoleCurrentFontEx)   ; 戻り値は stat
; hConsoleOutput : HANDLE -> "sptr"
; bMaximumWindow : BOOL -> "sptr"
; lpConsoleCurrentFontEx : CONSOLE_FONT_INFOEX* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global GetCurrentConsoleFontEx "GetCurrentConsoleFontEx" sptr, int, var
; res = GetCurrentConsoleFontEx(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFontEx)
; hConsoleOutput : HANDLE -> "sptr"
; bMaximumWindow : BOOL -> "int"
; lpConsoleCurrentFontEx : CONSOLE_FONT_INFOEX* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetCurrentConsoleFontEx(HANDLE hConsoleOutput, BOOL bMaximumWindow, CONSOLE_FONT_INFOEX* lpConsoleCurrentFontEx)
#uselib "KERNEL32.dll"
#cfunc global GetCurrentConsoleFontEx "GetCurrentConsoleFontEx" intptr, int, var
; res = GetCurrentConsoleFontEx(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFontEx)
; hConsoleOutput : HANDLE -> "intptr"
; bMaximumWindow : BOOL -> "int"
; lpConsoleCurrentFontEx : CONSOLE_FONT_INFOEX* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetCurrentConsoleFontEx = kernel32.NewProc("GetCurrentConsoleFontEx")
)

// hConsoleOutput (HANDLE), bMaximumWindow (BOOL), lpConsoleCurrentFontEx (CONSOLE_FONT_INFOEX* out)
r1, _, err := procGetCurrentConsoleFontEx.Call(
	uintptr(hConsoleOutput),
	uintptr(bMaximumWindow),
	uintptr(lpConsoleCurrentFontEx),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetCurrentConsoleFontEx(
  hConsoleOutput: THandle;   // HANDLE
  bMaximumWindow: BOOL;   // BOOL
  lpConsoleCurrentFontEx: Pointer   // CONSOLE_FONT_INFOEX* out
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'GetCurrentConsoleFontEx';
result := DllCall("KERNEL32\GetCurrentConsoleFontEx"
    , "Ptr", hConsoleOutput   ; HANDLE
    , "Int", bMaximumWindow   ; BOOL
    , "Ptr", lpConsoleCurrentFontEx   ; CONSOLE_FONT_INFOEX* out
    , "Int")   ; return: BOOL
●GetCurrentConsoleFontEx(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFontEx) = DLL("KERNEL32.dll", "bool GetCurrentConsoleFontEx(void*, bool, void*)")
# 呼び出し: GetCurrentConsoleFontEx(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFontEx)
# hConsoleOutput : HANDLE -> "void*"
# bMaximumWindow : BOOL -> "bool"
# lpConsoleCurrentFontEx : CONSOLE_FONT_INFOEX* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。