Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug.Extensions › OS_INFO_v1

OS_INFO_v1

構造体
サイズx64: 192 バイト / x86: 192 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
TypeOS_TYPE4+0+0OS種別を示すOS_TYPE列挙値。
Anonymous_Anonymous_e__Union8+8+8バージョン番号等を格納する無名共用体。
ProductTypeDWORD4+16+16製品種別を示す値。
SuiteDWORD4+20+20製品スイートを示すビットマスク。
s_s_e__Struct4+24+24サービスパック番号を格納する入れ子構造体。
SrvPackNumberDWORD4+28+28サービスパック番号。
LanguageCHAR30+32+32言語を表すNULL終端文字列。
OsStringCHAR64+62+62OSを表す文字列。
ServicePackStringCHAR64+126+126サービスパックを表す文字列。

共用体: _Anonymous_e__Union x64 8B / x86 8B

フィールドサイズx64x86
Version_Version_e__Struct8/4+0+0
Ver64ULONGLONG8+0+0

構造体: _s_e__Struct x64 4B / x86 4B

フィールドサイズx64x86
_bitfieldDWORD4+0+0

各言語での定義

#include <windows.h>

// OS_INFO_v1  (x64 192 / x86 192 バイト)
typedef struct OS_INFO_v1 {
    OS_TYPE Type;
    _Anonymous_e__Union Anonymous;
    DWORD ProductType;
    DWORD Suite;
    _s_e__Struct s;
    DWORD SrvPackNumber;
    CHAR Language[30];
    CHAR OsString[64];
    CHAR ServicePackString[64];
} OS_INFO_v1;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OS_INFO_v1
{
    public int Type;
    public _Anonymous_e__Union Anonymous;
    public uint ProductType;
    public uint Suite;
    public _s_e__Struct s;
    public uint SrvPackNumber;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)] public sbyte[] Language;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public sbyte[] OsString;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public sbyte[] ServicePackString;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure OS_INFO_v1
    Public Type As Integer
    Public Anonymous As _Anonymous_e__Union
    Public ProductType As UInteger
    Public Suite As UInteger
    Public s As _s_e__Struct
    Public SrvPackNumber As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=30)> Public Language() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public OsString() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public ServicePackString() As SByte
End Structure
import ctypes
from ctypes import wintypes

class OS_INFO_v1(ctypes.Structure):
    _fields_ = [
        ("Type", ctypes.c_int),
        ("Anonymous", _Anonymous_e__Union),
        ("ProductType", wintypes.DWORD),
        ("Suite", wintypes.DWORD),
        ("s", _s_e__Struct),
        ("SrvPackNumber", wintypes.DWORD),
        ("Language", ctypes.c_byte * 30),
        ("OsString", ctypes.c_byte * 64),
        ("ServicePackString", ctypes.c_byte * 64),
    ]
#[repr(C)]
pub struct OS_INFO_v1 {
    pub Type: i32,
    pub Anonymous: _Anonymous_e__Union,
    pub ProductType: u32,
    pub Suite: u32,
    pub s: _s_e__Struct,
    pub SrvPackNumber: u32,
    pub Language: [i8; 30],
    pub OsString: [i8; 64],
    pub ServicePackString: [i8; 64],
}
import "golang.org/x/sys/windows"

type OS_INFO_v1 struct {
	Type int32
	Anonymous _Anonymous_e__Union
	ProductType uint32
	Suite uint32
	s _s_e__Struct
	SrvPackNumber uint32
	Language [30]int8
	OsString [64]int8
	ServicePackString [64]int8
}
type
  OS_INFO_v1 = record
    Type: Integer;
    Anonymous: _Anonymous_e__Union;
    ProductType: DWORD;
    Suite: DWORD;
    s: _s_e__Struct;
    SrvPackNumber: DWORD;
    Language: array[0..29] of Shortint;
    OsString: array[0..63] of Shortint;
    ServicePackString: array[0..63] of Shortint;
  end;
const OS_INFO_v1 = extern struct {
    Type: i32,
    Anonymous: _Anonymous_e__Union,
    ProductType: u32,
    Suite: u32,
    s: _s_e__Struct,
    SrvPackNumber: u32,
    Language: [30]i8,
    OsString: [64]i8,
    ServicePackString: [64]i8,
};
type
  OS_INFO_v1 {.bycopy.} = object
    Type: int32
    Anonymous: _Anonymous_e__Union
    ProductType: uint32
    Suite: uint32
    s: _s_e__Struct
    SrvPackNumber: uint32
    Language: array[30, int8]
    OsString: array[64, int8]
    ServicePackString: array[64, int8]
struct OS_INFO_v1
{
    int Type;
    _Anonymous_e__Union Anonymous;
    uint ProductType;
    uint Suite;
    _s_e__Struct s;
    uint SrvPackNumber;
    byte[30] Language;
    byte[64] OsString;
    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_v1 サイズ: 192 バイト(x64)
dim st, 48    ; 4byte整数×48(構造体サイズ 192 / 4 切り上げ)
; Type : OS_TYPE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; ProductType : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; Suite : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; s : _s_e__Struct (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; SrvPackNumber : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; Language : CHAR (+32, 30byte)  varptr(st)+32 を基点に操作(30byte:入れ子/配列)
; OsString : CHAR (+62, 64byte)  varptr(st)+62 を基点に操作(64byte:入れ子/配列)
; ServicePackString : CHAR (+126, 64byte)  varptr(st)+126 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global OS_INFO_v1
    #field int Type
    #field byte Anonymous 8
    #field int ProductType
    #field int Suite
    #field _s_e__Struct s
    #field int SrvPackNumber
    #field byte Language 30
    #field byte OsString 64
    #field byte ServicePackString 64
#endstruct

stdim st, OS_INFO_v1        ; NSTRUCT 変数を確保
st->Type = 100
mes "Type=" + st->Type
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。