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

DRIVE_LAYOUT_INFORMATION_GPT

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

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

フィールド

フィールドサイズx64x86説明
DiskIdGUID16+0+0GPTディスクを識別するGUID。
StartingUsableOffsetLONGLONG8+16+16パーティションに使用可能な開始オフセット。バイト単位。
UsableLengthLONGLONG8+24+24パーティションに使用可能な領域の長さ。バイト単位。
MaxPartitionCountDWORD4+32+32作成可能な最大パーティション数。

各言語での定義

#include <windows.h>

// DRIVE_LAYOUT_INFORMATION_GPT  (x64 40 / x86 40 バイト)
typedef struct DRIVE_LAYOUT_INFORMATION_GPT {
    GUID DiskId;
    LONGLONG StartingUsableOffset;
    LONGLONG UsableLength;
    DWORD MaxPartitionCount;
} DRIVE_LAYOUT_INFORMATION_GPT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DRIVE_LAYOUT_INFORMATION_GPT
{
    public Guid DiskId;
    public long StartingUsableOffset;
    public long UsableLength;
    public uint MaxPartitionCount;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DRIVE_LAYOUT_INFORMATION_GPT
    Public DiskId As Guid
    Public StartingUsableOffset As Long
    Public UsableLength As Long
    Public MaxPartitionCount As UInteger
End Structure
import ctypes
from ctypes import wintypes

class DRIVE_LAYOUT_INFORMATION_GPT(ctypes.Structure):
    _fields_ = [
        ("DiskId", GUID),
        ("StartingUsableOffset", ctypes.c_longlong),
        ("UsableLength", ctypes.c_longlong),
        ("MaxPartitionCount", wintypes.DWORD),
    ]
#[repr(C)]
pub struct DRIVE_LAYOUT_INFORMATION_GPT {
    pub DiskId: GUID,
    pub StartingUsableOffset: i64,
    pub UsableLength: i64,
    pub MaxPartitionCount: u32,
}
import "golang.org/x/sys/windows"

type DRIVE_LAYOUT_INFORMATION_GPT struct {
	DiskId windows.GUID
	StartingUsableOffset int64
	UsableLength int64
	MaxPartitionCount uint32
}
type
  DRIVE_LAYOUT_INFORMATION_GPT = record
    DiskId: TGUID;
    StartingUsableOffset: Int64;
    UsableLength: Int64;
    MaxPartitionCount: DWORD;
  end;
const DRIVE_LAYOUT_INFORMATION_GPT = extern struct {
    DiskId: GUID,
    StartingUsableOffset: i64,
    UsableLength: i64,
    MaxPartitionCount: u32,
};
type
  DRIVE_LAYOUT_INFORMATION_GPT {.bycopy.} = object
    DiskId: GUID
    StartingUsableOffset: int64
    UsableLength: int64
    MaxPartitionCount: uint32
struct DRIVE_LAYOUT_INFORMATION_GPT
{
    GUID DiskId;
    long StartingUsableOffset;
    long UsableLength;
    uint MaxPartitionCount;
}

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_GPT サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; DiskId : GUID (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; StartingUsableOffset : LONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; UsableLength : LONGLONG (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; MaxPartitionCount : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
    #field int Data1
    #field short Data2
    #field short Data3
    #field byte Data4 8
#endstruct

#defstruct global DRIVE_LAYOUT_INFORMATION_GPT
    #field GUID DiskId
    #field int64 StartingUsableOffset
    #field int64 UsableLength
    #field int MaxPartitionCount
#endstruct

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