ホーム › System.WindowsProgramming › SYSTEM_BASIC_INFORMATION
SYSTEM_BASIC_INFORMATION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Reserved1 | BYTE | 24 | +0 | +0 | 予約バイト配列。 |
| Reserved2 | void* | 32/16 | +24 | +24 | 予約ポインタ配列(ページサイズやメモリ情報等)。 |
| NumberOfProcessors | CHAR | 1 | +56 | +40 | システムの論理プロセッサ数(CHAR)。 |
各言語での定義
#include <windows.h>
// SYSTEM_BASIC_INFORMATION (x64 64 / x86 44 バイト)
typedef struct SYSTEM_BASIC_INFORMATION {
BYTE Reserved1[24];
void* Reserved2[4];
CHAR NumberOfProcessors;
} SYSTEM_BASIC_INFORMATION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SYSTEM_BASIC_INFORMATION
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)] public byte[] Reserved1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public IntPtr[] Reserved2;
public sbyte NumberOfProcessors;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SYSTEM_BASIC_INFORMATION
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=24)> Public Reserved1() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public Reserved2() As IntPtr
Public NumberOfProcessors As SByte
End Structureimport ctypes
from ctypes import wintypes
class SYSTEM_BASIC_INFORMATION(ctypes.Structure):
_fields_ = [
("Reserved1", ctypes.c_ubyte * 24),
("Reserved2", ctypes.c_void_p * 4),
("NumberOfProcessors", ctypes.c_byte),
]#[repr(C)]
pub struct SYSTEM_BASIC_INFORMATION {
pub Reserved1: [u8; 24],
pub Reserved2: [*mut core::ffi::c_void; 4],
pub NumberOfProcessors: i8,
}import "golang.org/x/sys/windows"
type SYSTEM_BASIC_INFORMATION struct {
Reserved1 [24]byte
Reserved2 [4]uintptr
NumberOfProcessors int8
}type
SYSTEM_BASIC_INFORMATION = record
Reserved1: array[0..23] of Byte;
Reserved2: array[0..3] of Pointer;
NumberOfProcessors: Shortint;
end;const SYSTEM_BASIC_INFORMATION = extern struct {
Reserved1: [24]u8,
Reserved2: [4]?*anyopaque,
NumberOfProcessors: i8,
};type
SYSTEM_BASIC_INFORMATION {.bycopy.} = object
Reserved1: array[24, uint8]
Reserved2: array[4, pointer]
NumberOfProcessors: int8struct SYSTEM_BASIC_INFORMATION
{
ubyte[24] Reserved1;
void*[4] Reserved2;
byte NumberOfProcessors;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SYSTEM_BASIC_INFORMATION サイズ: 44 バイト(x86)
dim st, 11 ; 4byte整数×11(構造体サイズ 44 / 4 切り上げ)
; Reserved1 : BYTE (+0, 24byte) varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; Reserved2 : void* (+24, 16byte) varptr(st)+24 を基点に操作(16byte:入れ子/配列)
; NumberOfProcessors : CHAR (+40, 1byte) poke st,40,値 / 値 = peek(st,40)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SYSTEM_BASIC_INFORMATION サイズ: 64 バイト(x64)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; Reserved1 : BYTE (+0, 24byte) varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; Reserved2 : void* (+24, 32byte) varptr(st)+24 を基点に操作(32byte:入れ子/配列)
; NumberOfProcessors : CHAR (+56, 1byte) poke st,56,値 / 値 = peek(st,56)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SYSTEM_BASIC_INFORMATION
#field byte Reserved1 24
#field intptr Reserved2 4
#field byte NumberOfProcessors
#endstruct
stdim st, SYSTEM_BASIC_INFORMATION ; NSTRUCT 変数を確保
st->NumberOfProcessors = 100
mes "NumberOfProcessors=" + st->NumberOfProcessors