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

CPU_INFORMATION

共用体
サイズx64: 24 バイト / x86: 24 バイト

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

フィールド

フィールドサイズx64x86説明
X86CpuInfo_X86CpuInfo_e__Struct24+0+0x86向けCPUID結果(ベンダID/機能ビット)を格納する構造体。
OtherCpuInfo_OtherCpuInfo_e__Struct16+0+0非x86アーキテクチャ向けの機能ビット情報を格納する構造体。

構造体: _X86CpuInfo_e__Struct x64 24B / x86 24B

フィールドサイズx64x86
VendorIdDWORD12+0+0
VersionInformationDWORD4+12+12
FeatureInformationDWORD4+16+16
AMDExtendedCpuFeaturesDWORD4+20+20

構造体: _OtherCpuInfo_e__Struct x64 16B / x86 16B

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

各言語での定義

#include <windows.h>

// CPU_INFORMATION  (x64 24 / x86 24 バイト)
typedef struct CPU_INFORMATION {
    _X86CpuInfo_e__Struct X86CpuInfo;
    _OtherCpuInfo_e__Struct OtherCpuInfo;
} CPU_INFORMATION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CPU_INFORMATION
{
    public _X86CpuInfo_e__Struct X86CpuInfo;
    public _OtherCpuInfo_e__Struct OtherCpuInfo;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CPU_INFORMATION
    Public X86CpuInfo As _X86CpuInfo_e__Struct
    Public OtherCpuInfo As _OtherCpuInfo_e__Struct
End Structure
import ctypes
from ctypes import wintypes

class CPU_INFORMATION(ctypes.Structure):
    _fields_ = [
        ("X86CpuInfo", _X86CpuInfo_e__Struct),
        ("OtherCpuInfo", _OtherCpuInfo_e__Struct),
    ]
#[repr(C)]
pub struct CPU_INFORMATION {
    pub X86CpuInfo: _X86CpuInfo_e__Struct,
    pub OtherCpuInfo: _OtherCpuInfo_e__Struct,
}
import "golang.org/x/sys/windows"

type CPU_INFORMATION struct {
	X86CpuInfo _X86CpuInfo_e__Struct
	OtherCpuInfo _OtherCpuInfo_e__Struct
}
type
  CPU_INFORMATION = record
    X86CpuInfo: _X86CpuInfo_e__Struct;
    OtherCpuInfo: _OtherCpuInfo_e__Struct;
  end;
const CPU_INFORMATION = extern struct {
    X86CpuInfo: _X86CpuInfo_e__Struct,
    OtherCpuInfo: _OtherCpuInfo_e__Struct,
};
type
  CPU_INFORMATION {.bycopy.} = object
    X86CpuInfo: _X86CpuInfo_e__Struct
    OtherCpuInfo: _OtherCpuInfo_e__Struct
struct CPU_INFORMATION
{
    _X86CpuInfo_e__Struct X86CpuInfo;
    _OtherCpuInfo_e__Struct OtherCpuInfo;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CPU_INFORMATION サイズ: 24 バイト(x64)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; X86CpuInfo : _X86CpuInfo_e__Struct (+0, 24byte)  varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; OtherCpuInfo : _OtherCpuInfo_e__Struct (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CPU_INFORMATION
    #field _X86CpuInfo_e__Struct X86CpuInfo
    #field _OtherCpuInfo_e__Struct OtherCpuInfo
#endstruct

stdim st, CPU_INFORMATION        ; NSTRUCT 変数を確保