Win32 API 日本語リファレンス
ホームSystem.Ioctl › PHYSICAL_ELEMENT_STATUS

PHYSICAL_ELEMENT_STATUS

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

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

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0構造体のバージョン番号。
SizeDWORD4+4+4この構造体のサイズをバイト単位で示す。
DescriptorCountDWORD4+8+8存在する物理要素記述子の総数。
ReturnedDescriptorCountDWORD4+12+12Descriptors配列に実際に返された記述子数。
ElementIdentifierBeingDepopedDWORD4+16+16現在デポップ(切り離し)処理中の要素識別子。0なら処理なし。
ReservedDWORD4+20+20将来の拡張のために予約された32ビット領域。
DescriptorsPHYSICAL_ELEMENT_STATUS_DESCRIPTOR40+24+24PHYSICAL_ELEMENT_STATUS_DESCRIPTOR構造体の可変長配列。各物理要素の状態を保持する。

各言語での定義

#include <windows.h>

// PHYSICAL_ELEMENT_STATUS_DESCRIPTOR  (x64 40 / x86 40 バイト)
typedef struct PHYSICAL_ELEMENT_STATUS_DESCRIPTOR {
    DWORD Version;
    DWORD Size;
    DWORD ElementIdentifier;
    BYTE PhysicalElementType;
    BYTE PhysicalElementHealth;
    BYTE Reserved1[2];
    ULONGLONG AssociatedCapacity;
    DWORD Reserved2[4];
} PHYSICAL_ELEMENT_STATUS_DESCRIPTOR;

// PHYSICAL_ELEMENT_STATUS  (x64 64 / x86 64 バイト)
typedef struct PHYSICAL_ELEMENT_STATUS {
    DWORD Version;
    DWORD Size;
    DWORD DescriptorCount;
    DWORD ReturnedDescriptorCount;
    DWORD ElementIdentifierBeingDepoped;
    DWORD Reserved;
    PHYSICAL_ELEMENT_STATUS_DESCRIPTOR Descriptors[1];
} PHYSICAL_ELEMENT_STATUS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PHYSICAL_ELEMENT_STATUS_DESCRIPTOR
{
    public uint Version;
    public uint Size;
    public uint ElementIdentifier;
    public byte PhysicalElementType;
    public byte PhysicalElementHealth;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] Reserved1;
    public ulong AssociatedCapacity;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public uint[] Reserved2;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PHYSICAL_ELEMENT_STATUS
{
    public uint Version;
    public uint Size;
    public uint DescriptorCount;
    public uint ReturnedDescriptorCount;
    public uint ElementIdentifierBeingDepoped;
    public uint Reserved;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public PHYSICAL_ELEMENT_STATUS_DESCRIPTOR[] Descriptors;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PHYSICAL_ELEMENT_STATUS_DESCRIPTOR
    Public Version As UInteger
    Public Size As UInteger
    Public ElementIdentifier As UInteger
    Public PhysicalElementType As Byte
    Public PhysicalElementHealth As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public Reserved1() As Byte
    Public AssociatedCapacity As ULong
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public Reserved2() As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PHYSICAL_ELEMENT_STATUS
    Public Version As UInteger
    Public Size As UInteger
    Public DescriptorCount As UInteger
    Public ReturnedDescriptorCount As UInteger
    Public ElementIdentifierBeingDepoped As UInteger
    Public Reserved As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Descriptors() As PHYSICAL_ELEMENT_STATUS_DESCRIPTOR
End Structure
import ctypes
from ctypes import wintypes

class PHYSICAL_ELEMENT_STATUS_DESCRIPTOR(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("Size", wintypes.DWORD),
        ("ElementIdentifier", wintypes.DWORD),
        ("PhysicalElementType", ctypes.c_ubyte),
        ("PhysicalElementHealth", ctypes.c_ubyte),
        ("Reserved1", ctypes.c_ubyte * 2),
        ("AssociatedCapacity", ctypes.c_ulonglong),
        ("Reserved2", wintypes.DWORD * 4),
    ]

class PHYSICAL_ELEMENT_STATUS(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("Size", wintypes.DWORD),
        ("DescriptorCount", wintypes.DWORD),
        ("ReturnedDescriptorCount", wintypes.DWORD),
        ("ElementIdentifierBeingDepoped", wintypes.DWORD),
        ("Reserved", wintypes.DWORD),
        ("Descriptors", PHYSICAL_ELEMENT_STATUS_DESCRIPTOR * 1),
    ]
#[repr(C)]
pub struct PHYSICAL_ELEMENT_STATUS_DESCRIPTOR {
    pub Version: u32,
    pub Size: u32,
    pub ElementIdentifier: u32,
    pub PhysicalElementType: u8,
    pub PhysicalElementHealth: u8,
    pub Reserved1: [u8; 2],
    pub AssociatedCapacity: u64,
    pub Reserved2: [u32; 4],
}

#[repr(C)]
pub struct PHYSICAL_ELEMENT_STATUS {
    pub Version: u32,
    pub Size: u32,
    pub DescriptorCount: u32,
    pub ReturnedDescriptorCount: u32,
    pub ElementIdentifierBeingDepoped: u32,
    pub Reserved: u32,
    pub Descriptors: [PHYSICAL_ELEMENT_STATUS_DESCRIPTOR; 1],
}
import "golang.org/x/sys/windows"

type PHYSICAL_ELEMENT_STATUS_DESCRIPTOR struct {
	Version uint32
	Size uint32
	ElementIdentifier uint32
	PhysicalElementType byte
	PhysicalElementHealth byte
	Reserved1 [2]byte
	AssociatedCapacity uint64
	Reserved2 [4]uint32
}

type PHYSICAL_ELEMENT_STATUS struct {
	Version uint32
	Size uint32
	DescriptorCount uint32
	ReturnedDescriptorCount uint32
	ElementIdentifierBeingDepoped uint32
	Reserved uint32
	Descriptors [1]PHYSICAL_ELEMENT_STATUS_DESCRIPTOR
}
type
  PHYSICAL_ELEMENT_STATUS_DESCRIPTOR = record
    Version: DWORD;
    Size: DWORD;
    ElementIdentifier: DWORD;
    PhysicalElementType: Byte;
    PhysicalElementHealth: Byte;
    Reserved1: array[0..1] of Byte;
    AssociatedCapacity: UInt64;
    Reserved2: array[0..3] of DWORD;
  end;

  PHYSICAL_ELEMENT_STATUS = record
    Version: DWORD;
    Size: DWORD;
    DescriptorCount: DWORD;
    ReturnedDescriptorCount: DWORD;
    ElementIdentifierBeingDepoped: DWORD;
    Reserved: DWORD;
    Descriptors: array[0..0] of PHYSICAL_ELEMENT_STATUS_DESCRIPTOR;
  end;
const PHYSICAL_ELEMENT_STATUS_DESCRIPTOR = extern struct {
    Version: u32,
    Size: u32,
    ElementIdentifier: u32,
    PhysicalElementType: u8,
    PhysicalElementHealth: u8,
    Reserved1: [2]u8,
    AssociatedCapacity: u64,
    Reserved2: [4]u32,
};

const PHYSICAL_ELEMENT_STATUS = extern struct {
    Version: u32,
    Size: u32,
    DescriptorCount: u32,
    ReturnedDescriptorCount: u32,
    ElementIdentifierBeingDepoped: u32,
    Reserved: u32,
    Descriptors: [1]PHYSICAL_ELEMENT_STATUS_DESCRIPTOR,
};
type
  PHYSICAL_ELEMENT_STATUS_DESCRIPTOR {.bycopy.} = object
    Version: uint32
    Size: uint32
    ElementIdentifier: uint32
    PhysicalElementType: uint8
    PhysicalElementHealth: uint8
    Reserved1: array[2, uint8]
    AssociatedCapacity: uint64
    Reserved2: array[4, uint32]

  PHYSICAL_ELEMENT_STATUS {.bycopy.} = object
    Version: uint32
    Size: uint32
    DescriptorCount: uint32
    ReturnedDescriptorCount: uint32
    ElementIdentifierBeingDepoped: uint32
    Reserved: uint32
    Descriptors: array[1, PHYSICAL_ELEMENT_STATUS_DESCRIPTOR]
struct PHYSICAL_ELEMENT_STATUS_DESCRIPTOR
{
    uint Version;
    uint Size;
    uint ElementIdentifier;
    ubyte PhysicalElementType;
    ubyte PhysicalElementHealth;
    ubyte[2] Reserved1;
    ulong AssociatedCapacity;
    uint[4] Reserved2;
}

struct PHYSICAL_ELEMENT_STATUS
{
    uint Version;
    uint Size;
    uint DescriptorCount;
    uint ReturnedDescriptorCount;
    uint ElementIdentifierBeingDepoped;
    uint Reserved;
    PHYSICAL_ELEMENT_STATUS_DESCRIPTOR[1] Descriptors;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PHYSICAL_ELEMENT_STATUS サイズ: 64 バイト(x64)
dim st, 16    ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Size : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; DescriptorCount : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ReturnedDescriptorCount : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ElementIdentifierBeingDepoped : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; Reserved : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; Descriptors : PHYSICAL_ELEMENT_STATUS_DESCRIPTOR (+24, 40byte)  varptr(st)+24 を基点に操作(40byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global PHYSICAL_ELEMENT_STATUS_DESCRIPTOR
    #field int Version
    #field int Size
    #field int ElementIdentifier
    #field byte PhysicalElementType
    #field byte PhysicalElementHealth
    #field byte Reserved1 2
    #field int64 AssociatedCapacity
    #field int Reserved2 4
#endstruct

#defstruct global PHYSICAL_ELEMENT_STATUS
    #field int Version
    #field int Size
    #field int DescriptorCount
    #field int ReturnedDescriptorCount
    #field int ElementIdentifierBeingDepoped
    #field int Reserved
    #field PHYSICAL_ELEMENT_STATUS_DESCRIPTOR Descriptors 1
#endstruct

stdim st, PHYSICAL_ELEMENT_STATUS        ; NSTRUCT 変数を確保
st->Version = 100
mes "Version=" + st->Version