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

DRIVE_LAYOUT_INFORMATION

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

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

フィールド

フィールドサイズx64x86説明
PartitionCountDWORD4+0+0PartitionEntry配列に含まれるパーティション数。
SignatureDWORD4+4+4MBRディスクのシグネチャ。
PartitionEntryPARTITION_INFORMATION32+8+8PARTITION_INFORMATIONの可変長配列。先頭要素。

各言語での定義

#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;

// DRIVE_LAYOUT_INFORMATION  (x64 40 / x86 40 バイト)
typedef struct DRIVE_LAYOUT_INFORMATION {
    DWORD PartitionCount;
    DWORD Signature;
    PARTITION_INFORMATION PartitionEntry[1];
} DRIVE_LAYOUT_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;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DRIVE_LAYOUT_INFORMATION
{
    public uint PartitionCount;
    public uint Signature;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public PARTITION_INFORMATION[] PartitionEntry;
}
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

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DRIVE_LAYOUT_INFORMATION
    Public PartitionCount As UInteger
    Public Signature As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public PartitionEntry() As PARTITION_INFORMATION
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),
    ]

class DRIVE_LAYOUT_INFORMATION(ctypes.Structure):
    _fields_ = [
        ("PartitionCount", wintypes.DWORD),
        ("Signature", wintypes.DWORD),
        ("PartitionEntry", PARTITION_INFORMATION * 1),
    ]
#[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,
}

#[repr(C)]
pub struct DRIVE_LAYOUT_INFORMATION {
    pub PartitionCount: u32,
    pub Signature: u32,
    pub PartitionEntry: [PARTITION_INFORMATION; 1],
}
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 DRIVE_LAYOUT_INFORMATION struct {
	PartitionCount uint32
	Signature uint32
	PartitionEntry [1]PARTITION_INFORMATION
}
type
  PARTITION_INFORMATION = record
    StartingOffset: Int64;
    PartitionLength: Int64;
    HiddenSectors: DWORD;
    PartitionNumber: DWORD;
    PartitionType: Byte;
    BootIndicator: ByteBool;
    RecognizedPartition: ByteBool;
    RewritePartition: ByteBool;
  end;

  DRIVE_LAYOUT_INFORMATION = record
    PartitionCount: DWORD;
    Signature: DWORD;
    PartitionEntry: array[0..0] of PARTITION_INFORMATION;
  end;
const PARTITION_INFORMATION = extern struct {
    StartingOffset: i64,
    PartitionLength: i64,
    HiddenSectors: u32,
    PartitionNumber: u32,
    PartitionType: u8,
    BootIndicator: u8,
    RecognizedPartition: u8,
    RewritePartition: u8,
};

const DRIVE_LAYOUT_INFORMATION = extern struct {
    PartitionCount: u32,
    Signature: u32,
    PartitionEntry: [1]PARTITION_INFORMATION,
};
type
  PARTITION_INFORMATION {.bycopy.} = object
    StartingOffset: int64
    PartitionLength: int64
    HiddenSectors: uint32
    PartitionNumber: uint32
    PartitionType: uint8
    BootIndicator: uint8
    RecognizedPartition: uint8
    RewritePartition: uint8

  DRIVE_LAYOUT_INFORMATION {.bycopy.} = object
    PartitionCount: uint32
    Signature: uint32
    PartitionEntry: array[1, PARTITION_INFORMATION]
struct PARTITION_INFORMATION
{
    long StartingOffset;
    long PartitionLength;
    uint HiddenSectors;
    uint PartitionNumber;
    ubyte PartitionType;
    ubyte BootIndicator;
    ubyte RecognizedPartition;
    ubyte RewritePartition;
}

struct DRIVE_LAYOUT_INFORMATION
{
    uint PartitionCount;
    uint Signature;
    PARTITION_INFORMATION[1] PartitionEntry;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DRIVE_LAYOUT_INFORMATION サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; PartitionCount : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Signature : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; PartitionEntry : PARTITION_INFORMATION (+8, 32byte)  varptr(st)+8 を基点に操作(32byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#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

#defstruct global DRIVE_LAYOUT_INFORMATION
    #field int PartitionCount
    #field int Signature
    #field PARTITION_INFORMATION PartitionEntry 1
#endstruct

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