ホーム › System.Ioctl › DISK_GEOMETRY_EX
DISK_GEOMETRY_EX
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Geometry | DISK_GEOMETRY | 24 | +0 | +0 | ディスクの基本ジオメトリ情報。DISK_GEOMETRY構造体。 |
| DiskSize | LONGLONG | 8 | +24 | +24 | ディスクの総サイズ。バイト単位。 |
| Data | BYTE | 1 | +32 | +32 | パーティション情報や検出情報を含む可変長データ領域。先頭要素。 |
各言語での定義
#include <windows.h>
// DISK_GEOMETRY (x64 24 / x86 24 バイト)
typedef struct DISK_GEOMETRY {
LONGLONG Cylinders;
MEDIA_TYPE MediaType;
DWORD TracksPerCylinder;
DWORD SectorsPerTrack;
DWORD BytesPerSector;
} DISK_GEOMETRY;
// DISK_GEOMETRY_EX (x64 40 / x86 40 バイト)
typedef struct DISK_GEOMETRY_EX {
DISK_GEOMETRY Geometry;
LONGLONG DiskSize;
BYTE Data[1];
} DISK_GEOMETRY_EX;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DISK_GEOMETRY
{
public long Cylinders;
public int MediaType;
public uint TracksPerCylinder;
public uint SectorsPerTrack;
public uint BytesPerSector;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DISK_GEOMETRY_EX
{
public DISK_GEOMETRY Geometry;
public long DiskSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] Data;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DISK_GEOMETRY
Public Cylinders As Long
Public MediaType As Integer
Public TracksPerCylinder As UInteger
Public SectorsPerTrack As UInteger
Public BytesPerSector As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DISK_GEOMETRY_EX
Public Geometry As DISK_GEOMETRY
Public DiskSize As Long
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Data() As Byte
End Structureimport ctypes
from ctypes import wintypes
class DISK_GEOMETRY(ctypes.Structure):
_fields_ = [
("Cylinders", ctypes.c_longlong),
("MediaType", ctypes.c_int),
("TracksPerCylinder", wintypes.DWORD),
("SectorsPerTrack", wintypes.DWORD),
("BytesPerSector", wintypes.DWORD),
]
class DISK_GEOMETRY_EX(ctypes.Structure):
_fields_ = [
("Geometry", DISK_GEOMETRY),
("DiskSize", ctypes.c_longlong),
("Data", ctypes.c_ubyte * 1),
]#[repr(C)]
pub struct DISK_GEOMETRY {
pub Cylinders: i64,
pub MediaType: i32,
pub TracksPerCylinder: u32,
pub SectorsPerTrack: u32,
pub BytesPerSector: u32,
}
#[repr(C)]
pub struct DISK_GEOMETRY_EX {
pub Geometry: DISK_GEOMETRY,
pub DiskSize: i64,
pub Data: [u8; 1],
}import "golang.org/x/sys/windows"
type DISK_GEOMETRY struct {
Cylinders int64
MediaType int32
TracksPerCylinder uint32
SectorsPerTrack uint32
BytesPerSector uint32
}
type DISK_GEOMETRY_EX struct {
Geometry DISK_GEOMETRY
DiskSize int64
Data [1]byte
}type
DISK_GEOMETRY = record
Cylinders: Int64;
MediaType: Integer;
TracksPerCylinder: DWORD;
SectorsPerTrack: DWORD;
BytesPerSector: DWORD;
end;
DISK_GEOMETRY_EX = record
Geometry: DISK_GEOMETRY;
DiskSize: Int64;
Data: array[0..0] of Byte;
end;const DISK_GEOMETRY = extern struct {
Cylinders: i64,
MediaType: i32,
TracksPerCylinder: u32,
SectorsPerTrack: u32,
BytesPerSector: u32,
};
const DISK_GEOMETRY_EX = extern struct {
Geometry: DISK_GEOMETRY,
DiskSize: i64,
Data: [1]u8,
};type
DISK_GEOMETRY {.bycopy.} = object
Cylinders: int64
MediaType: int32
TracksPerCylinder: uint32
SectorsPerTrack: uint32
BytesPerSector: uint32
DISK_GEOMETRY_EX {.bycopy.} = object
Geometry: DISK_GEOMETRY
DiskSize: int64
Data: array[1, uint8]struct DISK_GEOMETRY
{
long Cylinders;
int MediaType;
uint TracksPerCylinder;
uint SectorsPerTrack;
uint BytesPerSector;
}
struct DISK_GEOMETRY_EX
{
DISK_GEOMETRY Geometry;
long DiskSize;
ubyte[1] Data;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DISK_GEOMETRY_EX サイズ: 40 バイト(x64)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; Geometry : DISK_GEOMETRY (+0, 24byte) varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; DiskSize : LONGLONG (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; Data : BYTE (+32, 1byte) varptr(st)+32 を基点に操作(1byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DISK_GEOMETRY
#field int64 Cylinders
#field int MediaType
#field int TracksPerCylinder
#field int SectorsPerTrack
#field int BytesPerSector
#endstruct
#defstruct global DISK_GEOMETRY_EX
#field DISK_GEOMETRY Geometry
#field int64 DiskSize
#field byte Data 1
#endstruct
stdim st, DISK_GEOMETRY_EX ; NSTRUCT 変数を確保
st->DiskSize = 100
mes "DiskSize=" + st->DiskSize