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

PARTITION_INFORMATION

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

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

フィールド

フィールドサイズx64x86説明
StartingOffsetLONGLONG8+0+0パーティションの開始オフセット。バイト単位。
PartitionLengthLONGLONG8+8+8パーティションの長さ。バイト単位。
HiddenSectorsDWORD4+16+16パーティション前方の隠しセクタ数。
PartitionNumberDWORD4+20+20パーティション番号。1始まり。
PartitionTypeBYTE1+24+24パーティション種別を示すMBRタイプコード。
BootIndicatorBOOLEAN1+25+25ブート可能パーティションかどうかを示す真偽値。
RecognizedPartitionBOOLEAN1+26+26OSが認識可能なパーティションかどうかを示す真偽値。
RewritePartitionBOOLEAN1+27+27パーティションテーブルを書き換えるかどうかを示す真偽値。

各言語での定義

#include <windows.h>

// PARTITION_INFORMATION  (x64 32 / x86 32 バイト)
typedef struct PARTITION_INFORMATION {
    LONGLONG StartingOffset;
    LONGLONG PartitionLength;
    DWORD HiddenSectors;
    DWORD PartitionNumber;
    BYTE PartitionType;
    BOOLEAN BootIndicator;
    BOOLEAN RecognizedPartition;
    BOOLEAN RewritePartition;
} PARTITION_INFORMATION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PARTITION_INFORMATION
{
    public long StartingOffset;
    public long PartitionLength;
    public uint HiddenSectors;
    public uint PartitionNumber;
    public byte PartitionType;
    [MarshalAs(UnmanagedType.U1)] public bool BootIndicator;
    [MarshalAs(UnmanagedType.U1)] public bool RecognizedPartition;
    [MarshalAs(UnmanagedType.U1)] public bool RewritePartition;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PARTITION_INFORMATION
    Public StartingOffset As Long
    Public PartitionLength As Long
    Public HiddenSectors As UInteger
    Public PartitionNumber As UInteger
    Public PartitionType As Byte
    <MarshalAs(UnmanagedType.U1)> Public BootIndicator As Boolean
    <MarshalAs(UnmanagedType.U1)> Public RecognizedPartition As Boolean
    <MarshalAs(UnmanagedType.U1)> Public RewritePartition As Boolean
End Structure
import ctypes
from ctypes import wintypes

class PARTITION_INFORMATION(ctypes.Structure):
    _fields_ = [
        ("StartingOffset", ctypes.c_longlong),
        ("PartitionLength", ctypes.c_longlong),
        ("HiddenSectors", wintypes.DWORD),
        ("PartitionNumber", wintypes.DWORD),
        ("PartitionType", ctypes.c_ubyte),
        ("BootIndicator", ctypes.c_byte),
        ("RecognizedPartition", ctypes.c_byte),
        ("RewritePartition", ctypes.c_byte),
    ]
#[repr(C)]
pub struct PARTITION_INFORMATION {
    pub StartingOffset: i64,
    pub PartitionLength: i64,
    pub HiddenSectors: u32,
    pub PartitionNumber: u32,
    pub PartitionType: u8,
    pub BootIndicator: u8,
    pub RecognizedPartition: u8,
    pub RewritePartition: u8,
}
import "golang.org/x/sys/windows"

type PARTITION_INFORMATION struct {
	StartingOffset int64
	PartitionLength int64
	HiddenSectors uint32
	PartitionNumber uint32
	PartitionType byte
	BootIndicator byte
	RecognizedPartition byte
	RewritePartition byte
}
type
  PARTITION_INFORMATION = record
    StartingOffset: Int64;
    PartitionLength: Int64;
    HiddenSectors: DWORD;
    PartitionNumber: DWORD;
    PartitionType: Byte;
    BootIndicator: ByteBool;
    RecognizedPartition: ByteBool;
    RewritePartition: ByteBool;
  end;
const PARTITION_INFORMATION = extern struct {
    StartingOffset: i64,
    PartitionLength: i64,
    HiddenSectors: u32,
    PartitionNumber: u32,
    PartitionType: u8,
    BootIndicator: u8,
    RecognizedPartition: u8,
    RewritePartition: u8,
};
type
  PARTITION_INFORMATION {.bycopy.} = object
    StartingOffset: int64
    PartitionLength: int64
    HiddenSectors: uint32
    PartitionNumber: uint32
    PartitionType: uint8
    BootIndicator: uint8
    RecognizedPartition: uint8
    RewritePartition: uint8
struct PARTITION_INFORMATION
{
    long StartingOffset;
    long PartitionLength;
    uint HiddenSectors;
    uint PartitionNumber;
    ubyte PartitionType;
    ubyte BootIndicator;
    ubyte RecognizedPartition;
    ubyte RewritePartition;
}

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 サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; StartingOffset : LONGLONG (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; PartitionLength : LONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; HiddenSectors : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; PartitionNumber : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; PartitionType : BYTE (+24, 1byte)  poke st,24,値  /  値 = peek(st,24)
; BootIndicator : BOOLEAN (+25, 1byte)  poke st,25,値  /  値 = peek(st,25)
; RecognizedPartition : BOOLEAN (+26, 1byte)  poke st,26,値  /  値 = peek(st,26)
; RewritePartition : BOOLEAN (+27, 1byte)  poke st,27,値  /  値 = peek(st,27)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PARTITION_INFORMATION
    #field int64 StartingOffset
    #field int64 PartitionLength
    #field int HiddenSectors
    #field int PartitionNumber
    #field byte PartitionType
    #field bool1 BootIndicator
    #field bool1 RecognizedPartition
    #field bool1 RewritePartition
#endstruct

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