ホーム › System.Diagnostics.Debug.Extensions › OS_INFO
OS_INFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| MajorVer | DWORD | 4 | +0 | +0 | OSのメジャーバージョン番号。例として10や6が入る。 |
| MinorVer | DWORD | 4 | +4 | +4 | OSのマイナーバージョン番号。 |
| Build | DWORD | 4 | +8 | +8 | OSのビルド番号。 |
| BuildQfe | DWORD | 4 | +12 | +12 | ビルドのQFE(修正プログラム)リビジョン番号。 |
| ProductType | DWORD | 4 | +16 | +16 | 製品種別を示す値。ワークステーションかサーバ等を表す。 |
| Suite | DWORD | 4 | +20 | +20 | インストールされている製品スイートを示すビットマスク。 |
| Revision | DWORD | 4 | +24 | +24 | OSのリビジョン番号。UBR相当。 |
| s | _s_e__Struct | 4 | +28 | +28 | サービスパックのメジャー/マイナー番号を格納する入れ子構造体。 |
| SrvPackNumber | DWORD | 4 | +32 | +32 | サービスパック番号。 |
| ServicePackBuild | DWORD | 4 | +36 | +36 | サービスパックのビルド番号。 |
| Architecture | DWORD | 4 | +40 | +40 | プロセッサアーキテクチャを示す値。x86/x64/ARM等。 |
| Lcid | DWORD | 4 | +44 | +44 | OSのロケール識別子(LCID)。 |
| Name | CHAR | 64 | +48 | +48 | OS名を表すNULL終端文字列(CHAR配列)。 |
| FullName | CHAR | 256 | +112 | +112 | OSの正式名称を表すNULL終端文字列。 |
| Language | CHAR | 30 | +368 | +368 | OSの言語名を表すNULL終端文字列。 |
| BuildVersion | CHAR | 64 | +398 | +398 | ビルドバージョン文字列。 |
| ServicePackString | CHAR | 64 | +462 | +462 | サービスパックを表す文字列。 |
構造体: _s_e__Struct x64 4B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| _bitfield | DWORD | 4 | +0 | +0 |
各言語での定義
#include <windows.h>
// OS_INFO (x64 528 / x86 528 バイト)
typedef struct OS_INFO {
DWORD MajorVer;
DWORD MinorVer;
DWORD Build;
DWORD BuildQfe;
DWORD ProductType;
DWORD Suite;
DWORD Revision;
_s_e__Struct s;
DWORD SrvPackNumber;
DWORD ServicePackBuild;
DWORD Architecture;
DWORD Lcid;
CHAR Name[64];
CHAR FullName[256];
CHAR Language[30];
CHAR BuildVersion[64];
CHAR ServicePackString[64];
} OS_INFO;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OS_INFO
{
public uint MajorVer;
public uint MinorVer;
public uint Build;
public uint BuildQfe;
public uint ProductType;
public uint Suite;
public uint Revision;
public _s_e__Struct s;
public uint SrvPackNumber;
public uint ServicePackBuild;
public uint Architecture;
public uint Lcid;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public sbyte[] Name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public sbyte[] FullName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)] public sbyte[] Language;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public sbyte[] BuildVersion;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public sbyte[] ServicePackString;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure OS_INFO
Public MajorVer As UInteger
Public MinorVer As UInteger
Public Build As UInteger
Public BuildQfe As UInteger
Public ProductType As UInteger
Public Suite As UInteger
Public Revision As UInteger
Public s As _s_e__Struct
Public SrvPackNumber As UInteger
Public ServicePackBuild As UInteger
Public Architecture As UInteger
Public Lcid As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public Name() As SByte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> Public FullName() As SByte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=30)> Public Language() As SByte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public BuildVersion() As SByte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public ServicePackString() As SByte
End Structureimport ctypes
from ctypes import wintypes
class OS_INFO(ctypes.Structure):
_fields_ = [
("MajorVer", wintypes.DWORD),
("MinorVer", wintypes.DWORD),
("Build", wintypes.DWORD),
("BuildQfe", wintypes.DWORD),
("ProductType", wintypes.DWORD),
("Suite", wintypes.DWORD),
("Revision", wintypes.DWORD),
("s", _s_e__Struct),
("SrvPackNumber", wintypes.DWORD),
("ServicePackBuild", wintypes.DWORD),
("Architecture", wintypes.DWORD),
("Lcid", wintypes.DWORD),
("Name", ctypes.c_byte * 64),
("FullName", ctypes.c_byte * 256),
("Language", ctypes.c_byte * 30),
("BuildVersion", ctypes.c_byte * 64),
("ServicePackString", ctypes.c_byte * 64),
]#[repr(C)]
pub struct OS_INFO {
pub MajorVer: u32,
pub MinorVer: u32,
pub Build: u32,
pub BuildQfe: u32,
pub ProductType: u32,
pub Suite: u32,
pub Revision: u32,
pub s: _s_e__Struct,
pub SrvPackNumber: u32,
pub ServicePackBuild: u32,
pub Architecture: u32,
pub Lcid: u32,
pub Name: [i8; 64],
pub FullName: [i8; 256],
pub Language: [i8; 30],
pub BuildVersion: [i8; 64],
pub ServicePackString: [i8; 64],
}import "golang.org/x/sys/windows"
type OS_INFO struct {
MajorVer uint32
MinorVer uint32
Build uint32
BuildQfe uint32
ProductType uint32
Suite uint32
Revision uint32
s _s_e__Struct
SrvPackNumber uint32
ServicePackBuild uint32
Architecture uint32
Lcid uint32
Name [64]int8
FullName [256]int8
Language [30]int8
BuildVersion [64]int8
ServicePackString [64]int8
}type
OS_INFO = record
MajorVer: DWORD;
MinorVer: DWORD;
Build: DWORD;
BuildQfe: DWORD;
ProductType: DWORD;
Suite: DWORD;
Revision: DWORD;
s: _s_e__Struct;
SrvPackNumber: DWORD;
ServicePackBuild: DWORD;
Architecture: DWORD;
Lcid: DWORD;
Name: array[0..63] of Shortint;
FullName: array[0..255] of Shortint;
Language: array[0..29] of Shortint;
BuildVersion: array[0..63] of Shortint;
ServicePackString: array[0..63] of Shortint;
end;const OS_INFO = extern struct {
MajorVer: u32,
MinorVer: u32,
Build: u32,
BuildQfe: u32,
ProductType: u32,
Suite: u32,
Revision: u32,
s: _s_e__Struct,
SrvPackNumber: u32,
ServicePackBuild: u32,
Architecture: u32,
Lcid: u32,
Name: [64]i8,
FullName: [256]i8,
Language: [30]i8,
BuildVersion: [64]i8,
ServicePackString: [64]i8,
};type
OS_INFO {.bycopy.} = object
MajorVer: uint32
MinorVer: uint32
Build: uint32
BuildQfe: uint32
ProductType: uint32
Suite: uint32
Revision: uint32
s: _s_e__Struct
SrvPackNumber: uint32
ServicePackBuild: uint32
Architecture: uint32
Lcid: uint32
Name: array[64, int8]
FullName: array[256, int8]
Language: array[30, int8]
BuildVersion: array[64, int8]
ServicePackString: array[64, int8]struct OS_INFO
{
uint MajorVer;
uint MinorVer;
uint Build;
uint BuildQfe;
uint ProductType;
uint Suite;
uint Revision;
_s_e__Struct s;
uint SrvPackNumber;
uint ServicePackBuild;
uint Architecture;
uint Lcid;
byte[64] Name;
byte[256] FullName;
byte[30] Language;
byte[64] BuildVersion;
byte[64] ServicePackString;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; OS_INFO サイズ: 528 バイト(x64)
dim st, 132 ; 4byte整数×132(構造体サイズ 528 / 4 切り上げ)
; MajorVer : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; MinorVer : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Build : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; BuildQfe : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; ProductType : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; Suite : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; Revision : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; s : _s_e__Struct (+28, 4byte) varptr(st)+28 を基点に操作(4byte:入れ子/配列)
; SrvPackNumber : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; ServicePackBuild : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; Architecture : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; Lcid : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; Name : CHAR (+48, 64byte) varptr(st)+48 を基点に操作(64byte:入れ子/配列)
; FullName : CHAR (+112, 256byte) varptr(st)+112 を基点に操作(256byte:入れ子/配列)
; Language : CHAR (+368, 30byte) varptr(st)+368 を基点に操作(30byte:入れ子/配列)
; BuildVersion : CHAR (+398, 64byte) varptr(st)+398 を基点に操作(64byte:入れ子/配列)
; ServicePackString : CHAR (+462, 64byte) varptr(st)+462 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global OS_INFO
#field int MajorVer
#field int MinorVer
#field int Build
#field int BuildQfe
#field int ProductType
#field int Suite
#field int Revision
#field _s_e__Struct s
#field int SrvPackNumber
#field int ServicePackBuild
#field int Architecture
#field int Lcid
#field byte Name 64
#field byte FullName 256
#field byte Language 30
#field byte BuildVersion 64
#field byte ServicePackString 64
#endstruct
stdim st, OS_INFO ; NSTRUCT 変数を確保
st->MajorVer = 100
mes "MajorVer=" + st->MajorVer