Win32 API 日本語リファレンス
ホームStorage.VirtualDiskService › VDS_DRIVE_PROP2

VDS_DRIVE_PROP2

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

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

フィールド

フィールドサイズx64x86説明
idGUID16+0+0物理ドライブを一意に識別するGUID。
ullSizeULONGLONG8+16+16ドライブの容量をバイト単位で示す。
pwszFriendlyNameLPWSTR8/4+24+24ドライブのユーザー向け表示名を表すワイド文字列。
pwszIdentificationLPWSTR8/4+32+28ドライブの識別文字列(ワイド文字)。
ulFlagsDWORD4+40+32ドライブの属性を示すVDS_DRIVE_FLAGビットフラグ。
statusVDS_DRIVE_STATUS4+44+36ドライブの状態を示すVDS_DRIVE_STATUS列挙値。
healthVDS_HEALTH4+48+40ドライブの正常性を示すVDS_HEALTH列挙値。
sInternalBusNumberSHORT2+52+44ドライブが接続される内部バス番号を示す符号付き値。
sSlotNumberSHORT2+54+46ドライブが装着されるスロット番号を示す符号付き値。
ulEnclosureNumberDWORD4+56+48ドライブが収容されるエンクロージャ番号。
busTypeVDS_STORAGE_BUS_TYPE4+60+52ドライブの接続バス種類を示すVDS_STORAGE_BUS_TYPE列挙値。
ulSpindleSpeedDWORD4+64+56ドライブの回転数(RPM)。SSDなどでは0となる。

各言語での定義

#include <windows.h>

// VDS_DRIVE_PROP2  (x64 72 / x86 64 バイト)
typedef struct VDS_DRIVE_PROP2 {
    GUID id;
    ULONGLONG ullSize;
    LPWSTR pwszFriendlyName;
    LPWSTR pwszIdentification;
    DWORD ulFlags;
    VDS_DRIVE_STATUS status;
    VDS_HEALTH health;
    SHORT sInternalBusNumber;
    SHORT sSlotNumber;
    DWORD ulEnclosureNumber;
    VDS_STORAGE_BUS_TYPE busType;
    DWORD ulSpindleSpeed;
} VDS_DRIVE_PROP2;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct VDS_DRIVE_PROP2
{
    public Guid id;
    public ulong ullSize;
    public IntPtr pwszFriendlyName;
    public IntPtr pwszIdentification;
    public uint ulFlags;
    public int status;
    public int health;
    public short sInternalBusNumber;
    public short sSlotNumber;
    public uint ulEnclosureNumber;
    public int busType;
    public uint ulSpindleSpeed;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure VDS_DRIVE_PROP2
    Public id As Guid
    Public ullSize As ULong
    Public pwszFriendlyName As IntPtr
    Public pwszIdentification As IntPtr
    Public ulFlags As UInteger
    Public status As Integer
    Public health As Integer
    Public sInternalBusNumber As Short
    Public sSlotNumber As Short
    Public ulEnclosureNumber As UInteger
    Public busType As Integer
    Public ulSpindleSpeed As UInteger
End Structure
import ctypes
from ctypes import wintypes

class VDS_DRIVE_PROP2(ctypes.Structure):
    _fields_ = [
        ("id", GUID),
        ("ullSize", ctypes.c_ulonglong),
        ("pwszFriendlyName", ctypes.c_void_p),
        ("pwszIdentification", ctypes.c_void_p),
        ("ulFlags", wintypes.DWORD),
        ("status", ctypes.c_int),
        ("health", ctypes.c_int),
        ("sInternalBusNumber", ctypes.c_short),
        ("sSlotNumber", ctypes.c_short),
        ("ulEnclosureNumber", wintypes.DWORD),
        ("busType", ctypes.c_int),
        ("ulSpindleSpeed", wintypes.DWORD),
    ]
#[repr(C)]
pub struct VDS_DRIVE_PROP2 {
    pub id: GUID,
    pub ullSize: u64,
    pub pwszFriendlyName: *mut core::ffi::c_void,
    pub pwszIdentification: *mut core::ffi::c_void,
    pub ulFlags: u32,
    pub status: i32,
    pub health: i32,
    pub sInternalBusNumber: i16,
    pub sSlotNumber: i16,
    pub ulEnclosureNumber: u32,
    pub busType: i32,
    pub ulSpindleSpeed: u32,
}
import "golang.org/x/sys/windows"

type VDS_DRIVE_PROP2 struct {
	id windows.GUID
	ullSize uint64
	pwszFriendlyName uintptr
	pwszIdentification uintptr
	ulFlags uint32
	status int32
	health int32
	sInternalBusNumber int16
	sSlotNumber int16
	ulEnclosureNumber uint32
	busType int32
	ulSpindleSpeed uint32
}
type
  VDS_DRIVE_PROP2 = record
    id: TGUID;
    ullSize: UInt64;
    pwszFriendlyName: Pointer;
    pwszIdentification: Pointer;
    ulFlags: DWORD;
    status: Integer;
    health: Integer;
    sInternalBusNumber: Smallint;
    sSlotNumber: Smallint;
    ulEnclosureNumber: DWORD;
    busType: Integer;
    ulSpindleSpeed: DWORD;
  end;
const VDS_DRIVE_PROP2 = extern struct {
    id: GUID,
    ullSize: u64,
    pwszFriendlyName: ?*anyopaque,
    pwszIdentification: ?*anyopaque,
    ulFlags: u32,
    status: i32,
    health: i32,
    sInternalBusNumber: i16,
    sSlotNumber: i16,
    ulEnclosureNumber: u32,
    busType: i32,
    ulSpindleSpeed: u32,
};
type
  VDS_DRIVE_PROP2 {.bycopy.} = object
    id: GUID
    ullSize: uint64
    pwszFriendlyName: pointer
    pwszIdentification: pointer
    ulFlags: uint32
    status: int32
    health: int32
    sInternalBusNumber: int16
    sSlotNumber: int16
    ulEnclosureNumber: uint32
    busType: int32
    ulSpindleSpeed: uint32
struct VDS_DRIVE_PROP2
{
    GUID id;
    ulong ullSize;
    void* pwszFriendlyName;
    void* pwszIdentification;
    uint ulFlags;
    int status;
    int health;
    short sInternalBusNumber;
    short sSlotNumber;
    uint ulEnclosureNumber;
    int busType;
    uint ulSpindleSpeed;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; VDS_DRIVE_PROP2 サイズ: 64 バイト(x86)
dim st, 16    ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; id : GUID (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; ullSize : ULONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; pwszFriendlyName : LPWSTR (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; pwszIdentification : LPWSTR (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ulFlags : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; status : VDS_DRIVE_STATUS (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; health : VDS_HEALTH (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; sInternalBusNumber : SHORT (+44, 2byte)  wpoke st,44,値  /  値 = wpeek(st,44)
; sSlotNumber : SHORT (+46, 2byte)  wpoke st,46,値  /  値 = wpeek(st,46)
; ulEnclosureNumber : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; busType : VDS_STORAGE_BUS_TYPE (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; ulSpindleSpeed : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; VDS_DRIVE_PROP2 サイズ: 72 バイト(x64)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; id : GUID (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; ullSize : ULONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; pwszFriendlyName : LPWSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; pwszIdentification : LPWSTR (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ulFlags : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; status : VDS_DRIVE_STATUS (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; health : VDS_HEALTH (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; sInternalBusNumber : SHORT (+52, 2byte)  wpoke st,52,値  /  値 = wpeek(st,52)
; sSlotNumber : SHORT (+54, 2byte)  wpoke st,54,値  /  値 = wpeek(st,54)
; ulEnclosureNumber : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; busType : VDS_STORAGE_BUS_TYPE (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; ulSpindleSpeed : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (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 VDS_DRIVE_PROP2
    #field GUID id
    #field int64 ullSize
    #field intptr pwszFriendlyName
    #field intptr pwszIdentification
    #field int ulFlags
    #field int status
    #field int health
    #field short sInternalBusNumber
    #field short sSlotNumber
    #field int ulEnclosureNumber
    #field int busType
    #field int ulSpindleSpeed
#endstruct

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