ホーム › System.Console › GetCurrentConsoleFont
GetCurrentConsoleFont
関数コンソールで現在使用中のフォント情報を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL GetCurrentConsoleFont(
HANDLE hConsoleOutput,
BOOL bMaximumWindow,
CONSOLE_FONT_INFO* lpConsoleCurrentFont
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hConsoleOutput | HANDLE | in |
| bMaximumWindow | BOOL | in |
| lpConsoleCurrentFont | CONSOLE_FONT_INFO* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL GetCurrentConsoleFont(
HANDLE hConsoleOutput,
BOOL bMaximumWindow,
CONSOLE_FONT_INFO* lpConsoleCurrentFont
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetCurrentConsoleFont(
IntPtr hConsoleOutput, // HANDLE
bool bMaximumWindow, // BOOL
IntPtr lpConsoleCurrentFont // CONSOLE_FONT_INFO* out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetCurrentConsoleFont(
hConsoleOutput As IntPtr, ' HANDLE
bMaximumWindow As Boolean, ' BOOL
lpConsoleCurrentFont As IntPtr ' CONSOLE_FONT_INFO* out
) As Boolean
End Function' hConsoleOutput : HANDLE
' bMaximumWindow : BOOL
' lpConsoleCurrentFont : CONSOLE_FONT_INFO* out
Declare PtrSafe Function GetCurrentConsoleFont Lib "kernel32" ( _
ByVal hConsoleOutput As LongPtr, _
ByVal bMaximumWindow As Long, _
ByVal lpConsoleCurrentFont As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetCurrentConsoleFont = ctypes.windll.kernel32.GetCurrentConsoleFont
GetCurrentConsoleFont.restype = wintypes.BOOL
GetCurrentConsoleFont.argtypes = [
wintypes.HANDLE, # hConsoleOutput : HANDLE
wintypes.BOOL, # bMaximumWindow : BOOL
ctypes.c_void_p, # lpConsoleCurrentFont : CONSOLE_FONT_INFO* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetCurrentConsoleFont = Fiddle::Function.new(
lib['GetCurrentConsoleFont'],
[
Fiddle::TYPE_VOIDP, # hConsoleOutput : HANDLE
Fiddle::TYPE_INT, # bMaximumWindow : BOOL
Fiddle::TYPE_VOIDP, # lpConsoleCurrentFont : CONSOLE_FONT_INFO* out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetCurrentConsoleFont(
hConsoleOutput: *mut core::ffi::c_void, // HANDLE
bMaximumWindow: i32, // BOOL
lpConsoleCurrentFont: *mut CONSOLE_FONT_INFO // CONSOLE_FONT_INFO* 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 GetCurrentConsoleFont(IntPtr hConsoleOutput, bool bMaximumWindow, IntPtr lpConsoleCurrentFont);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetCurrentConsoleFont' -Namespace Win32 -PassThru
# $api::GetCurrentConsoleFont(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFont)#uselib "KERNEL32.dll"
#func global GetCurrentConsoleFont "GetCurrentConsoleFont" sptr, sptr, sptr
; GetCurrentConsoleFont hConsoleOutput, bMaximumWindow, varptr(lpConsoleCurrentFont) ; 戻り値は stat
; hConsoleOutput : HANDLE -> "sptr"
; bMaximumWindow : BOOL -> "sptr"
; lpConsoleCurrentFont : CONSOLE_FONT_INFO* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetCurrentConsoleFont "GetCurrentConsoleFont" sptr, int, var ; res = GetCurrentConsoleFont(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFont) ; hConsoleOutput : HANDLE -> "sptr" ; bMaximumWindow : BOOL -> "int" ; lpConsoleCurrentFont : CONSOLE_FONT_INFO* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetCurrentConsoleFont "GetCurrentConsoleFont" sptr, int, sptr ; res = GetCurrentConsoleFont(hConsoleOutput, bMaximumWindow, varptr(lpConsoleCurrentFont)) ; hConsoleOutput : HANDLE -> "sptr" ; bMaximumWindow : BOOL -> "int" ; lpConsoleCurrentFont : CONSOLE_FONT_INFO* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetCurrentConsoleFont(HANDLE hConsoleOutput, BOOL bMaximumWindow, CONSOLE_FONT_INFO* lpConsoleCurrentFont) #uselib "KERNEL32.dll" #cfunc global GetCurrentConsoleFont "GetCurrentConsoleFont" intptr, int, var ; res = GetCurrentConsoleFont(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFont) ; hConsoleOutput : HANDLE -> "intptr" ; bMaximumWindow : BOOL -> "int" ; lpConsoleCurrentFont : CONSOLE_FONT_INFO* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetCurrentConsoleFont(HANDLE hConsoleOutput, BOOL bMaximumWindow, CONSOLE_FONT_INFO* lpConsoleCurrentFont) #uselib "KERNEL32.dll" #cfunc global GetCurrentConsoleFont "GetCurrentConsoleFont" intptr, int, intptr ; res = GetCurrentConsoleFont(hConsoleOutput, bMaximumWindow, varptr(lpConsoleCurrentFont)) ; hConsoleOutput : HANDLE -> "intptr" ; bMaximumWindow : BOOL -> "int" ; lpConsoleCurrentFont : CONSOLE_FONT_INFO* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetCurrentConsoleFont = kernel32.NewProc("GetCurrentConsoleFont")
)
// hConsoleOutput (HANDLE), bMaximumWindow (BOOL), lpConsoleCurrentFont (CONSOLE_FONT_INFO* out)
r1, _, err := procGetCurrentConsoleFont.Call(
uintptr(hConsoleOutput),
uintptr(bMaximumWindow),
uintptr(lpConsoleCurrentFont),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetCurrentConsoleFont(
hConsoleOutput: THandle; // HANDLE
bMaximumWindow: BOOL; // BOOL
lpConsoleCurrentFont: Pointer // CONSOLE_FONT_INFO* out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'GetCurrentConsoleFont';result := DllCall("KERNEL32\GetCurrentConsoleFont"
, "Ptr", hConsoleOutput ; HANDLE
, "Int", bMaximumWindow ; BOOL
, "Ptr", lpConsoleCurrentFont ; CONSOLE_FONT_INFO* out
, "Int") ; return: BOOL●GetCurrentConsoleFont(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFont) = DLL("KERNEL32.dll", "bool GetCurrentConsoleFont(void*, bool, void*)")
# 呼び出し: GetCurrentConsoleFont(hConsoleOutput, bMaximumWindow, lpConsoleCurrentFont)
# hConsoleOutput : HANDLE -> "void*"
# bMaximumWindow : BOOL -> "bool"
# lpConsoleCurrentFont : CONSOLE_FONT_INFO* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。