ホーム › System.Console › SetConsoleFont
SetConsoleFont
関数コンソールで使用するフォントをインデックス指定で設定する内部関数。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL SetConsoleFont(
HANDLE hConsoleOutput,
DWORD nFont
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hConsoleOutput | HANDLE | in |
| nFont | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL SetConsoleFont(
HANDLE hConsoleOutput,
DWORD nFont
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool SetConsoleFont(
IntPtr hConsoleOutput, // HANDLE
uint nFont // DWORD
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function SetConsoleFont(
hConsoleOutput As IntPtr, ' HANDLE
nFont As UInteger ' DWORD
) As Boolean
End Function' hConsoleOutput : HANDLE
' nFont : DWORD
Declare PtrSafe Function SetConsoleFont Lib "kernel32" ( _
ByVal hConsoleOutput As LongPtr, _
ByVal nFont As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetConsoleFont = ctypes.windll.kernel32.SetConsoleFont
SetConsoleFont.restype = wintypes.BOOL
SetConsoleFont.argtypes = [
wintypes.HANDLE, # hConsoleOutput : HANDLE
wintypes.DWORD, # nFont : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
SetConsoleFont = Fiddle::Function.new(
lib['SetConsoleFont'],
[
Fiddle::TYPE_VOIDP, # hConsoleOutput : HANDLE
-Fiddle::TYPE_INT, # nFont : DWORD
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn SetConsoleFont(
hConsoleOutput: *mut core::ffi::c_void, // HANDLE
nFont: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool SetConsoleFont(IntPtr hConsoleOutput, uint nFont);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetConsoleFont' -Namespace Win32 -PassThru
# $api::SetConsoleFont(hConsoleOutput, nFont)#uselib "KERNEL32.dll"
#func global SetConsoleFont "SetConsoleFont" sptr, sptr
; SetConsoleFont hConsoleOutput, nFont ; 戻り値は stat
; hConsoleOutput : HANDLE -> "sptr"
; nFont : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global SetConsoleFont "SetConsoleFont" sptr, int
; res = SetConsoleFont(hConsoleOutput, nFont)
; hConsoleOutput : HANDLE -> "sptr"
; nFont : DWORD -> "int"; BOOL SetConsoleFont(HANDLE hConsoleOutput, DWORD nFont)
#uselib "KERNEL32.dll"
#cfunc global SetConsoleFont "SetConsoleFont" intptr, int
; res = SetConsoleFont(hConsoleOutput, nFont)
; hConsoleOutput : HANDLE -> "intptr"
; nFont : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procSetConsoleFont = kernel32.NewProc("SetConsoleFont")
)
// hConsoleOutput (HANDLE), nFont (DWORD)
r1, _, err := procSetConsoleFont.Call(
uintptr(hConsoleOutput),
uintptr(nFont),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetConsoleFont(
hConsoleOutput: THandle; // HANDLE
nFont: DWORD // DWORD
): BOOL; stdcall;
external 'KERNEL32.dll' name 'SetConsoleFont';result := DllCall("KERNEL32\SetConsoleFont"
, "Ptr", hConsoleOutput ; HANDLE
, "UInt", nFont ; DWORD
, "Int") ; return: BOOL●SetConsoleFont(hConsoleOutput, nFont) = DLL("KERNEL32.dll", "bool SetConsoleFont(void*, dword)")
# 呼び出し: SetConsoleFont(hConsoleOutput, nFont)
# hConsoleOutput : HANDLE -> "void*"
# nFont : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。