NT_CONSOLE_PROPS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dbh | DATABLOCK_HEADER | 8 | +0 | +0 | データブロックヘッダ。サイズとシグネチャを保持する。 |
| wFillAttribute | WORD | 2 | +8 | +8 | 画面の文字・背景色属性。 |
| wPopupFillAttribute | WORD | 2 | +10 | +10 | ポップアップ表示の文字・背景色属性。 |
| dwScreenBufferSize | COORD | 4 | +12 | +12 | スクリーンバッファのサイズ(列・行、COORD)。 |
| dwWindowSize | COORD | 4 | +16 | +16 | コンソールウィンドウのサイズ(列・行、COORD)。 |
| dwWindowOrigin | COORD | 4 | +20 | +20 | ウィンドウの原点位置(COORD)。 |
| nFont | DWORD | 4 | +24 | +24 | フォントのインデックス。 |
| nInputBufferSize | DWORD | 4 | +28 | +28 | 入力バッファのサイズ。 |
| dwFontSize | COORD | 4 | +32 | +32 | フォントのサイズ(幅・高さ、COORD)。 |
| uFontFamily | DWORD | 4 | +36 | +36 | フォントファミリの種別。 |
| uFontWeight | DWORD | 4 | +40 | +40 | フォントの太さ(ウェイト)。 |
| FaceName | WCHAR | 64 | +44 | +44 | フォントのフェイス名(Unicode固定長配列)。 |
| uCursorSize | DWORD | 4 | +108 | +108 | カーソルのサイズ(セル高に対する割合%)。 |
| bFullScreen | BOOL | 4 | +112 | +112 | 全画面表示にするかを示すブール値。 |
| bQuickEdit | BOOL | 4 | +116 | +116 | 簡易編集モードを有効にするかを示すブール値。 |
| bInsertMode | BOOL | 4 | +120 | +120 | 挿入モードを有効にするかを示すブール値。 |
| bAutoPosition | BOOL | 4 | +124 | +124 | ウィンドウ位置を自動配置するかを示すブール値。 |
| uHistoryBufferSize | DWORD | 4 | +128 | +128 | コマンド履歴バッファのサイズ。 |
| uNumberOfHistoryBuffers | DWORD | 4 | +132 | +132 | 履歴バッファの数。 |
| bHistoryNoDup | BOOL | 4 | +136 | +136 | 履歴の重複を除外するかを示すブール値。 |
| ColorTable | COLORREF | 64 | +140 | +140 | コンソールの16色カラーパレット(COLORREF配列)。 |
各言語での定義
#include <windows.h>
// DATABLOCK_HEADER (x64 8 / x86 8 バイト)
#pragma pack(push, 1)
typedef struct DATABLOCK_HEADER {
DWORD cbSize;
DWORD dwSignature;
} DATABLOCK_HEADER;
#pragma pack(pop)
// COORD (x64 4 / x86 4 バイト)
typedef struct COORD {
SHORT X;
SHORT Y;
} COORD;
// NT_CONSOLE_PROPS (x64 204 / x86 204 バイト)
#pragma pack(push, 1)
typedef struct NT_CONSOLE_PROPS {
DATABLOCK_HEADER dbh;
WORD wFillAttribute;
WORD wPopupFillAttribute;
COORD dwScreenBufferSize;
COORD dwWindowSize;
COORD dwWindowOrigin;
DWORD nFont;
DWORD nInputBufferSize;
COORD dwFontSize;
DWORD uFontFamily;
DWORD uFontWeight;
WCHAR FaceName[32];
DWORD uCursorSize;
BOOL bFullScreen;
BOOL bQuickEdit;
BOOL bInsertMode;
BOOL bAutoPosition;
DWORD uHistoryBufferSize;
DWORD uNumberOfHistoryBuffers;
BOOL bHistoryNoDup;
COLORREF ColorTable[16];
} NT_CONSOLE_PROPS;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct DATABLOCK_HEADER
{
public uint cbSize;
public uint dwSignature;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct COORD
{
public short X;
public short Y;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct NT_CONSOLE_PROPS
{
public DATABLOCK_HEADER dbh;
public ushort wFillAttribute;
public ushort wPopupFillAttribute;
public COORD dwScreenBufferSize;
public COORD dwWindowSize;
public COORD dwWindowOrigin;
public uint nFont;
public uint nInputBufferSize;
public COORD dwFontSize;
public uint uFontFamily;
public uint uFontWeight;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string FaceName;
public uint uCursorSize;
[MarshalAs(UnmanagedType.Bool)] public bool bFullScreen;
[MarshalAs(UnmanagedType.Bool)] public bool bQuickEdit;
[MarshalAs(UnmanagedType.Bool)] public bool bInsertMode;
[MarshalAs(UnmanagedType.Bool)] public bool bAutoPosition;
public uint uHistoryBufferSize;
public uint uNumberOfHistoryBuffers;
[MarshalAs(UnmanagedType.Bool)] public bool bHistoryNoDup;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public uint[] ColorTable;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure DATABLOCK_HEADER
Public cbSize As UInteger
Public dwSignature As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure COORD
Public X As Short
Public Y As Short
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure NT_CONSOLE_PROPS
Public dbh As DATABLOCK_HEADER
Public wFillAttribute As UShort
Public wPopupFillAttribute As UShort
Public dwScreenBufferSize As COORD
Public dwWindowSize As COORD
Public dwWindowOrigin As COORD
Public nFont As UInteger
Public nInputBufferSize As UInteger
Public dwFontSize As COORD
Public uFontFamily As UInteger
Public uFontWeight As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public FaceName As String
Public uCursorSize As UInteger
<MarshalAs(UnmanagedType.Bool)> Public bFullScreen As Boolean
<MarshalAs(UnmanagedType.Bool)> Public bQuickEdit As Boolean
<MarshalAs(UnmanagedType.Bool)> Public bInsertMode As Boolean
<MarshalAs(UnmanagedType.Bool)> Public bAutoPosition As Boolean
Public uHistoryBufferSize As UInteger
Public uNumberOfHistoryBuffers As UInteger
<MarshalAs(UnmanagedType.Bool)> Public bHistoryNoDup As Boolean
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public ColorTable() As UInteger
End Structureimport ctypes
from ctypes import wintypes
class DATABLOCK_HEADER(ctypes.Structure):
_pack_ = 1
_fields_ = [
("cbSize", wintypes.DWORD),
("dwSignature", wintypes.DWORD),
]
class COORD(ctypes.Structure):
_fields_ = [
("X", ctypes.c_short),
("Y", ctypes.c_short),
]
class NT_CONSOLE_PROPS(ctypes.Structure):
_pack_ = 1
_fields_ = [
("dbh", DATABLOCK_HEADER),
("wFillAttribute", ctypes.c_ushort),
("wPopupFillAttribute", ctypes.c_ushort),
("dwScreenBufferSize", COORD),
("dwWindowSize", COORD),
("dwWindowOrigin", COORD),
("nFont", wintypes.DWORD),
("nInputBufferSize", wintypes.DWORD),
("dwFontSize", COORD),
("uFontFamily", wintypes.DWORD),
("uFontWeight", wintypes.DWORD),
("FaceName", ctypes.c_wchar * 32),
("uCursorSize", wintypes.DWORD),
("bFullScreen", wintypes.BOOL),
("bQuickEdit", wintypes.BOOL),
("bInsertMode", wintypes.BOOL),
("bAutoPosition", wintypes.BOOL),
("uHistoryBufferSize", wintypes.DWORD),
("uNumberOfHistoryBuffers", wintypes.DWORD),
("bHistoryNoDup", wintypes.BOOL),
("ColorTable", wintypes.DWORD * 16),
]#[repr(C, packed(1))]
pub struct DATABLOCK_HEADER {
pub cbSize: u32,
pub dwSignature: u32,
}
#[repr(C)]
pub struct COORD {
pub X: i16,
pub Y: i16,
}
#[repr(C, packed(1))]
pub struct NT_CONSOLE_PROPS {
pub dbh: DATABLOCK_HEADER,
pub wFillAttribute: u16,
pub wPopupFillAttribute: u16,
pub dwScreenBufferSize: COORD,
pub dwWindowSize: COORD,
pub dwWindowOrigin: COORD,
pub nFont: u32,
pub nInputBufferSize: u32,
pub dwFontSize: COORD,
pub uFontFamily: u32,
pub uFontWeight: u32,
pub FaceName: [u16; 32],
pub uCursorSize: u32,
pub bFullScreen: i32,
pub bQuickEdit: i32,
pub bInsertMode: i32,
pub bAutoPosition: i32,
pub uHistoryBufferSize: u32,
pub uNumberOfHistoryBuffers: u32,
pub bHistoryNoDup: i32,
pub ColorTable: [u32; 16],
}import "golang.org/x/sys/windows"
type DATABLOCK_HEADER struct {
cbSize uint32
dwSignature uint32
}
type COORD struct {
X int16
Y int16
}
type NT_CONSOLE_PROPS struct {
dbh DATABLOCK_HEADER
wFillAttribute uint16
wPopupFillAttribute uint16
dwScreenBufferSize COORD
dwWindowSize COORD
dwWindowOrigin COORD
nFont uint32
nInputBufferSize uint32
dwFontSize COORD
uFontFamily uint32
uFontWeight uint32
FaceName [32]uint16
uCursorSize uint32
bFullScreen int32
bQuickEdit int32
bInsertMode int32
bAutoPosition int32
uHistoryBufferSize uint32
uNumberOfHistoryBuffers uint32
bHistoryNoDup int32
ColorTable [16]uint32
}type
DATABLOCK_HEADER = packed record
cbSize: DWORD;
dwSignature: DWORD;
end;
COORD = record
X: Smallint;
Y: Smallint;
end;
NT_CONSOLE_PROPS = packed record
dbh: DATABLOCK_HEADER;
wFillAttribute: Word;
wPopupFillAttribute: Word;
dwScreenBufferSize: COORD;
dwWindowSize: COORD;
dwWindowOrigin: COORD;
nFont: DWORD;
nInputBufferSize: DWORD;
dwFontSize: COORD;
uFontFamily: DWORD;
uFontWeight: DWORD;
FaceName: array[0..31] of WideChar;
uCursorSize: DWORD;
bFullScreen: BOOL;
bQuickEdit: BOOL;
bInsertMode: BOOL;
bAutoPosition: BOOL;
uHistoryBufferSize: DWORD;
uNumberOfHistoryBuffers: DWORD;
bHistoryNoDup: BOOL;
ColorTable: array[0..15] of DWORD;
end;const DATABLOCK_HEADER = extern struct {
cbSize: u32,
dwSignature: u32,
};
const COORD = extern struct {
X: i16,
Y: i16,
};
const NT_CONSOLE_PROPS = extern struct {
dbh: DATABLOCK_HEADER,
wFillAttribute: u16,
wPopupFillAttribute: u16,
dwScreenBufferSize: COORD,
dwWindowSize: COORD,
dwWindowOrigin: COORD,
nFont: u32,
nInputBufferSize: u32,
dwFontSize: COORD,
uFontFamily: u32,
uFontWeight: u32,
FaceName: [32]u16,
uCursorSize: u32,
bFullScreen: i32,
bQuickEdit: i32,
bInsertMode: i32,
bAutoPosition: i32,
uHistoryBufferSize: u32,
uNumberOfHistoryBuffers: u32,
bHistoryNoDup: i32,
ColorTable: [16]u32,
};type
DATABLOCK_HEADER {.packed.} = object
cbSize: uint32
dwSignature: uint32
COORD {.bycopy.} = object
X: int16
Y: int16
NT_CONSOLE_PROPS {.packed.} = object
dbh: DATABLOCK_HEADER
wFillAttribute: uint16
wPopupFillAttribute: uint16
dwScreenBufferSize: COORD
dwWindowSize: COORD
dwWindowOrigin: COORD
nFont: uint32
nInputBufferSize: uint32
dwFontSize: COORD
uFontFamily: uint32
uFontWeight: uint32
FaceName: array[32, uint16]
uCursorSize: uint32
bFullScreen: int32
bQuickEdit: int32
bInsertMode: int32
bAutoPosition: int32
uHistoryBufferSize: uint32
uNumberOfHistoryBuffers: uint32
bHistoryNoDup: int32
ColorTable: array[16, uint32]align(1)
struct DATABLOCK_HEADER
{
uint cbSize;
uint dwSignature;
}
struct COORD
{
short X;
short Y;
}
align(1)
struct NT_CONSOLE_PROPS
{
DATABLOCK_HEADER dbh;
ushort wFillAttribute;
ushort wPopupFillAttribute;
COORD dwScreenBufferSize;
COORD dwWindowSize;
COORD dwWindowOrigin;
uint nFont;
uint nInputBufferSize;
COORD dwFontSize;
uint uFontFamily;
uint uFontWeight;
wchar[32] FaceName;
uint uCursorSize;
int bFullScreen;
int bQuickEdit;
int bInsertMode;
int bAutoPosition;
uint uHistoryBufferSize;
uint uNumberOfHistoryBuffers;
int bHistoryNoDup;
uint[16] ColorTable;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NT_CONSOLE_PROPS サイズ: 204 バイト(x64)
dim st, 51 ; 4byte整数×51(構造体サイズ 204 / 4 切り上げ)
; dbh : DATABLOCK_HEADER (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; wFillAttribute : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; wPopupFillAttribute : WORD (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; dwScreenBufferSize : COORD (+12, 4byte) varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; dwWindowSize : COORD (+16, 4byte) varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; dwWindowOrigin : COORD (+20, 4byte) varptr(st)+20 を基点に操作(4byte:入れ子/配列)
; nFont : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; nInputBufferSize : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; dwFontSize : COORD (+32, 4byte) varptr(st)+32 を基点に操作(4byte:入れ子/配列)
; uFontFamily : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; uFontWeight : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; FaceName : WCHAR (+44, 64byte) varptr(st)+44 を基点に操作(64byte:入れ子/配列)
; uCursorSize : DWORD (+108, 4byte) st.27 = 値 / 値 = st.27 (lpoke/lpeek も可)
; bFullScreen : BOOL (+112, 4byte) st.28 = 値 / 値 = st.28 (lpoke/lpeek も可)
; bQuickEdit : BOOL (+116, 4byte) st.29 = 値 / 値 = st.29 (lpoke/lpeek も可)
; bInsertMode : BOOL (+120, 4byte) st.30 = 値 / 値 = st.30 (lpoke/lpeek も可)
; bAutoPosition : BOOL (+124, 4byte) st.31 = 値 / 値 = st.31 (lpoke/lpeek も可)
; uHistoryBufferSize : DWORD (+128, 4byte) st.32 = 値 / 値 = st.32 (lpoke/lpeek も可)
; uNumberOfHistoryBuffers : DWORD (+132, 4byte) st.33 = 値 / 値 = st.33 (lpoke/lpeek も可)
; bHistoryNoDup : BOOL (+136, 4byte) st.34 = 値 / 値 = st.34 (lpoke/lpeek も可)
; ColorTable : COLORREF (+140, 64byte) varptr(st)+140 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DATABLOCK_HEADER, pack=1
#field int cbSize
#field int dwSignature
#endstruct
#defstruct global COORD
#field short X
#field short Y
#endstruct
#defstruct global NT_CONSOLE_PROPS, pack=1
#field DATABLOCK_HEADER dbh
#field short wFillAttribute
#field short wPopupFillAttribute
#field COORD dwScreenBufferSize
#field COORD dwWindowSize
#field COORD dwWindowOrigin
#field int nFont
#field int nInputBufferSize
#field COORD dwFontSize
#field int uFontFamily
#field int uFontWeight
#field wchar FaceName 32
#field int uCursorSize
#field bool bFullScreen
#field bool bQuickEdit
#field bool bInsertMode
#field bool bAutoPosition
#field int uHistoryBufferSize
#field int uNumberOfHistoryBuffers
#field bool bHistoryNoDup
#field int ColorTable 16
#endstruct
stdim st, NT_CONSOLE_PROPS ; NSTRUCT 変数を確保
st->wFillAttribute = 100
mes "wFillAttribute=" + st->wFillAttribute