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

PARTITION_INFORMATION_EX

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

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

フィールド

フィールドサイズx64x86説明
PartitionStylePARTITION_STYLE4+0+0パーティション形式(MBRまたはGPT)を示す列挙値。
StartingOffsetLONGLONG8+8+8パーティションの開始オフセット。バイト単位。
PartitionLengthLONGLONG8+16+16パーティションの長さ。バイト単位。
PartitionNumberDWORD4+24+24パーティション番号。1始まり。
RewritePartitionBOOLEAN1+28+28パーティションテーブルを書き換えるかどうかを示す真偽値。
IsServicePartitionBOOLEAN1+29+29サービスパーティションかどうかを示す真偽値。
Anonymous_Anonymous_e__Union112+32+32PartitionStyleに応じてMBRまたはGPT情報を保持する共用体。

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

フィールドサイズx64x86
MbrPARTITION_INFORMATION_MBR24+0+0
GptPARTITION_INFORMATION_GPT112+0+0

各言語での定義

#include <windows.h>

// PARTITION_INFORMATION_EX  (x64 144 / x86 144 バイト)
typedef struct PARTITION_INFORMATION_EX {
    PARTITION_STYLE PartitionStyle;
    LONGLONG StartingOffset;
    LONGLONG PartitionLength;
    DWORD PartitionNumber;
    BOOLEAN RewritePartition;
    BOOLEAN IsServicePartition;
    _Anonymous_e__Union Anonymous;
} PARTITION_INFORMATION_EX;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PARTITION_INFORMATION_EX
{
    public int PartitionStyle;
    public long StartingOffset;
    public long PartitionLength;
    public uint PartitionNumber;
    [MarshalAs(UnmanagedType.U1)] public bool RewritePartition;
    [MarshalAs(UnmanagedType.U1)] public bool IsServicePartition;
    public _Anonymous_e__Union Anonymous;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PARTITION_INFORMATION_EX
    Public PartitionStyle As Integer
    Public StartingOffset As Long
    Public PartitionLength As Long
    Public PartitionNumber As UInteger
    <MarshalAs(UnmanagedType.U1)> Public RewritePartition As Boolean
    <MarshalAs(UnmanagedType.U1)> Public IsServicePartition As Boolean
    Public Anonymous As _Anonymous_e__Union
End Structure
import ctypes
from ctypes import wintypes

class PARTITION_INFORMATION_EX(ctypes.Structure):
    _fields_ = [
        ("PartitionStyle", ctypes.c_int),
        ("StartingOffset", ctypes.c_longlong),
        ("PartitionLength", ctypes.c_longlong),
        ("PartitionNumber", wintypes.DWORD),
        ("RewritePartition", ctypes.c_byte),
        ("IsServicePartition", ctypes.c_byte),
        ("Anonymous", _Anonymous_e__Union),
    ]
#[repr(C)]
pub struct PARTITION_INFORMATION_EX {
    pub PartitionStyle: i32,
    pub StartingOffset: i64,
    pub PartitionLength: i64,
    pub PartitionNumber: u32,
    pub RewritePartition: u8,
    pub IsServicePartition: u8,
    pub Anonymous: _Anonymous_e__Union,
}
import "golang.org/x/sys/windows"

type PARTITION_INFORMATION_EX struct {
	PartitionStyle int32
	StartingOffset int64
	PartitionLength int64
	PartitionNumber uint32
	RewritePartition byte
	IsServicePartition byte
	Anonymous _Anonymous_e__Union
}
type
  PARTITION_INFORMATION_EX = record
    PartitionStyle: Integer;
    StartingOffset: Int64;
    PartitionLength: Int64;
    PartitionNumber: DWORD;
    RewritePartition: ByteBool;
    IsServicePartition: ByteBool;
    Anonymous: _Anonymous_e__Union;
  end;
const PARTITION_INFORMATION_EX = extern struct {
    PartitionStyle: i32,
    StartingOffset: i64,
    PartitionLength: i64,
    PartitionNumber: u32,
    RewritePartition: u8,
    IsServicePartition: u8,
    Anonymous: _Anonymous_e__Union,
};
type
  PARTITION_INFORMATION_EX {.bycopy.} = object
    PartitionStyle: int32
    StartingOffset: int64
    PartitionLength: int64
    PartitionNumber: uint32
    RewritePartition: uint8
    IsServicePartition: uint8
    Anonymous: _Anonymous_e__Union
struct PARTITION_INFORMATION_EX
{
    int PartitionStyle;
    long StartingOffset;
    long PartitionLength;
    uint PartitionNumber;
    ubyte RewritePartition;
    ubyte IsServicePartition;
    _Anonymous_e__Union Anonymous;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PARTITION_INFORMATION_EX サイズ: 144 バイト(x64)
dim st, 36    ; 4byte整数×36(構造体サイズ 144 / 4 切り上げ)
; PartitionStyle : PARTITION_STYLE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; StartingOffset : LONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; PartitionLength : LONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; PartitionNumber : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; RewritePartition : BOOLEAN (+28, 1byte)  poke st,28,値  /  値 = peek(st,28)
; IsServicePartition : BOOLEAN (+29, 1byte)  poke st,29,値  /  値 = peek(st,29)
; Anonymous : _Anonymous_e__Union (+32, 112byte)  varptr(st)+32 を基点に操作(112byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PARTITION_INFORMATION_EX
    #field int PartitionStyle
    #field int64 StartingOffset
    #field int64 PartitionLength
    #field int PartitionNumber
    #field bool1 RewritePartition
    #field bool1 IsServicePartition
    #field byte Anonymous 112
#endstruct

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