ホーム › Storage.FileSystem › NTMS_DRIVEINFORMATIONW
NTMS_DRIVEINFORMATIONW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Number | DWORD | 4 | +0 | +0 | ライブラリ内のドライブ番号。 |
| State | DWORD | 4 | +4 | +4 | ドライブの現在の状態を示す値。 |
| DriveType | GUID | 16 | +8 | +8 | ドライブ種別を識別するGUID。 |
| szDeviceName | WCHAR | 128 | +24 | +24 | デバイス名を格納するUnicode文字配列。 |
| szSerialNumber | WCHAR | 64 | +152 | +152 | ドライブのシリアル番号を格納するUnicode文字配列。 |
| szRevision | WCHAR | 64 | +216 | +216 | ドライブのリビジョン文字列。Unicode。 |
| ScsiPort | WORD | 2 | +280 | +280 | ドライブが接続されたSCSIポート番号。 |
| ScsiBus | WORD | 2 | +282 | +282 | ドライブのSCSIバス番号。 |
| ScsiTarget | WORD | 2 | +284 | +284 | ドライブのSCSIターゲットID。 |
| ScsiLun | WORD | 2 | +286 | +286 | ドライブのSCSI論理ユニット番号。 |
| dwMountCount | DWORD | 4 | +288 | +288 | ドライブのマウント累計回数。 |
| LastCleanedTs | SYSTEMTIME | 16 | +292 | +292 | 最後にクリーニングした日時。SYSTEMTIME。 |
| SavedPartitionId | GUID | 16 | +308 | +308 | 保存されたパーティションを識別するGUID。 |
| Library | GUID | 16 | +324 | +324 | ドライブが属するライブラリのGUID。 |
| Reserved | GUID | 16 | +340 | +340 | 予約フィールド。GUID形式。 |
| dwDeferDismountDelay | DWORD | 4 | +356 | +356 | ディスマウントを延期する遅延時間。秒単位。 |
各言語での定義
#include <windows.h>
// SYSTEMTIME (x64 16 / x86 16 バイト)
typedef struct SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
// NTMS_DRIVEINFORMATIONW (x64 360 / x86 360 バイト)
typedef struct NTMS_DRIVEINFORMATIONW {
DWORD Number;
DWORD State;
GUID DriveType;
WCHAR szDeviceName[64];
WCHAR szSerialNumber[32];
WCHAR szRevision[32];
WORD ScsiPort;
WORD ScsiBus;
WORD ScsiTarget;
WORD ScsiLun;
DWORD dwMountCount;
SYSTEMTIME LastCleanedTs;
GUID SavedPartitionId;
GUID Library;
GUID Reserved;
DWORD dwDeferDismountDelay;
} NTMS_DRIVEINFORMATIONW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SYSTEMTIME
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NTMS_DRIVEINFORMATIONW
{
public uint Number;
public uint State;
public Guid DriveType;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string szDeviceName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string szSerialNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string szRevision;
public ushort ScsiPort;
public ushort ScsiBus;
public ushort ScsiTarget;
public ushort ScsiLun;
public uint dwMountCount;
public SYSTEMTIME LastCleanedTs;
public Guid SavedPartitionId;
public Guid Library;
public Guid Reserved;
public uint dwDeferDismountDelay;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SYSTEMTIME
Public wYear As UShort
Public wMonth As UShort
Public wDayOfWeek As UShort
Public wDay As UShort
Public wHour As UShort
Public wMinute As UShort
Public wSecond As UShort
Public wMilliseconds As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NTMS_DRIVEINFORMATIONW
Public Number As UInteger
Public State As UInteger
Public DriveType As Guid
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> Public szDeviceName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public szSerialNumber As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public szRevision As String
Public ScsiPort As UShort
Public ScsiBus As UShort
Public ScsiTarget As UShort
Public ScsiLun As UShort
Public dwMountCount As UInteger
Public LastCleanedTs As SYSTEMTIME
Public SavedPartitionId As Guid
Public Library As Guid
Public Reserved As Guid
Public dwDeferDismountDelay As UInteger
End Structureimport ctypes
from ctypes import wintypes
class SYSTEMTIME(ctypes.Structure):
_fields_ = [
("wYear", ctypes.c_ushort),
("wMonth", ctypes.c_ushort),
("wDayOfWeek", ctypes.c_ushort),
("wDay", ctypes.c_ushort),
("wHour", ctypes.c_ushort),
("wMinute", ctypes.c_ushort),
("wSecond", ctypes.c_ushort),
("wMilliseconds", ctypes.c_ushort),
]
class NTMS_DRIVEINFORMATIONW(ctypes.Structure):
_fields_ = [
("Number", wintypes.DWORD),
("State", wintypes.DWORD),
("DriveType", GUID),
("szDeviceName", ctypes.c_wchar * 64),
("szSerialNumber", ctypes.c_wchar * 32),
("szRevision", ctypes.c_wchar * 32),
("ScsiPort", ctypes.c_ushort),
("ScsiBus", ctypes.c_ushort),
("ScsiTarget", ctypes.c_ushort),
("ScsiLun", ctypes.c_ushort),
("dwMountCount", wintypes.DWORD),
("LastCleanedTs", SYSTEMTIME),
("SavedPartitionId", GUID),
("Library", GUID),
("Reserved", GUID),
("dwDeferDismountDelay", wintypes.DWORD),
]#[repr(C)]
pub struct SYSTEMTIME {
pub wYear: u16,
pub wMonth: u16,
pub wDayOfWeek: u16,
pub wDay: u16,
pub wHour: u16,
pub wMinute: u16,
pub wSecond: u16,
pub wMilliseconds: u16,
}
#[repr(C)]
pub struct NTMS_DRIVEINFORMATIONW {
pub Number: u32,
pub State: u32,
pub DriveType: GUID,
pub szDeviceName: [u16; 64],
pub szSerialNumber: [u16; 32],
pub szRevision: [u16; 32],
pub ScsiPort: u16,
pub ScsiBus: u16,
pub ScsiTarget: u16,
pub ScsiLun: u16,
pub dwMountCount: u32,
pub LastCleanedTs: SYSTEMTIME,
pub SavedPartitionId: GUID,
pub Library: GUID,
pub Reserved: GUID,
pub dwDeferDismountDelay: u32,
}import "golang.org/x/sys/windows"
type SYSTEMTIME struct {
wYear uint16
wMonth uint16
wDayOfWeek uint16
wDay uint16
wHour uint16
wMinute uint16
wSecond uint16
wMilliseconds uint16
}
type NTMS_DRIVEINFORMATIONW struct {
Number uint32
State uint32
DriveType windows.GUID
szDeviceName [64]uint16
szSerialNumber [32]uint16
szRevision [32]uint16
ScsiPort uint16
ScsiBus uint16
ScsiTarget uint16
ScsiLun uint16
dwMountCount uint32
LastCleanedTs SYSTEMTIME
SavedPartitionId windows.GUID
Library windows.GUID
Reserved windows.GUID
dwDeferDismountDelay uint32
}type
SYSTEMTIME = record
wYear: Word;
wMonth: Word;
wDayOfWeek: Word;
wDay: Word;
wHour: Word;
wMinute: Word;
wSecond: Word;
wMilliseconds: Word;
end;
NTMS_DRIVEINFORMATIONW = record
Number: DWORD;
State: DWORD;
DriveType: TGUID;
szDeviceName: array[0..63] of WideChar;
szSerialNumber: array[0..31] of WideChar;
szRevision: array[0..31] of WideChar;
ScsiPort: Word;
ScsiBus: Word;
ScsiTarget: Word;
ScsiLun: Word;
dwMountCount: DWORD;
LastCleanedTs: SYSTEMTIME;
SavedPartitionId: TGUID;
Library: TGUID;
Reserved: TGUID;
dwDeferDismountDelay: DWORD;
end;const SYSTEMTIME = extern struct {
wYear: u16,
wMonth: u16,
wDayOfWeek: u16,
wDay: u16,
wHour: u16,
wMinute: u16,
wSecond: u16,
wMilliseconds: u16,
};
const NTMS_DRIVEINFORMATIONW = extern struct {
Number: u32,
State: u32,
DriveType: GUID,
szDeviceName: [64]u16,
szSerialNumber: [32]u16,
szRevision: [32]u16,
ScsiPort: u16,
ScsiBus: u16,
ScsiTarget: u16,
ScsiLun: u16,
dwMountCount: u32,
LastCleanedTs: SYSTEMTIME,
SavedPartitionId: GUID,
Library: GUID,
Reserved: GUID,
dwDeferDismountDelay: u32,
};type
SYSTEMTIME {.bycopy.} = object
wYear: uint16
wMonth: uint16
wDayOfWeek: uint16
wDay: uint16
wHour: uint16
wMinute: uint16
wSecond: uint16
wMilliseconds: uint16
NTMS_DRIVEINFORMATIONW {.bycopy.} = object
Number: uint32
State: uint32
DriveType: GUID
szDeviceName: array[64, uint16]
szSerialNumber: array[32, uint16]
szRevision: array[32, uint16]
ScsiPort: uint16
ScsiBus: uint16
ScsiTarget: uint16
ScsiLun: uint16
dwMountCount: uint32
LastCleanedTs: SYSTEMTIME
SavedPartitionId: GUID
Library: GUID
Reserved: GUID
dwDeferDismountDelay: uint32struct SYSTEMTIME
{
ushort wYear;
ushort wMonth;
ushort wDayOfWeek;
ushort wDay;
ushort wHour;
ushort wMinute;
ushort wSecond;
ushort wMilliseconds;
}
struct NTMS_DRIVEINFORMATIONW
{
uint Number;
uint State;
GUID DriveType;
wchar[64] szDeviceName;
wchar[32] szSerialNumber;
wchar[32] szRevision;
ushort ScsiPort;
ushort ScsiBus;
ushort ScsiTarget;
ushort ScsiLun;
uint dwMountCount;
SYSTEMTIME LastCleanedTs;
GUID SavedPartitionId;
GUID Library;
GUID Reserved;
uint dwDeferDismountDelay;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NTMS_DRIVEINFORMATIONW サイズ: 360 バイト(x64)
dim st, 90 ; 4byte整数×90(構造体サイズ 360 / 4 切り上げ)
; Number : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; State : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; DriveType : GUID (+8, 16byte) varptr(st)+8 を基点に操作(16byte:入れ子/配列)
; szDeviceName : WCHAR (+24, 128byte) varptr(st)+24 を基点に操作(128byte:入れ子/配列)
; szSerialNumber : WCHAR (+152, 64byte) varptr(st)+152 を基点に操作(64byte:入れ子/配列)
; szRevision : WCHAR (+216, 64byte) varptr(st)+216 を基点に操作(64byte:入れ子/配列)
; ScsiPort : WORD (+280, 2byte) wpoke st,280,値 / 値 = wpeek(st,280)
; ScsiBus : WORD (+282, 2byte) wpoke st,282,値 / 値 = wpeek(st,282)
; ScsiTarget : WORD (+284, 2byte) wpoke st,284,値 / 値 = wpeek(st,284)
; ScsiLun : WORD (+286, 2byte) wpoke st,286,値 / 値 = wpeek(st,286)
; dwMountCount : DWORD (+288, 4byte) st.72 = 値 / 値 = st.72 (lpoke/lpeek も可)
; LastCleanedTs : SYSTEMTIME (+292, 16byte) varptr(st)+292 を基点に操作(16byte:入れ子/配列)
; SavedPartitionId : GUID (+308, 16byte) varptr(st)+308 を基点に操作(16byte:入れ子/配列)
; Library : GUID (+324, 16byte) varptr(st)+324 を基点に操作(16byte:入れ子/配列)
; Reserved : GUID (+340, 16byte) varptr(st)+340 を基点に操作(16byte:入れ子/配列)
; dwDeferDismountDelay : DWORD (+356, 4byte) st.89 = 値 / 値 = st.89 (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 SYSTEMTIME
#field short wYear
#field short wMonth
#field short wDayOfWeek
#field short wDay
#field short wHour
#field short wMinute
#field short wSecond
#field short wMilliseconds
#endstruct
#defstruct global NTMS_DRIVEINFORMATIONW
#field int Number
#field int State
#field GUID DriveType
#field wchar szDeviceName 64
#field wchar szSerialNumber 32
#field wchar szRevision 32
#field short ScsiPort
#field short ScsiBus
#field short ScsiTarget
#field short ScsiLun
#field int dwMountCount
#field SYSTEMTIME LastCleanedTs
#field GUID SavedPartitionId
#field GUID Library
#field GUID Reserved
#field int dwDeferDismountDelay
#endstruct
stdim st, NTMS_DRIVEINFORMATIONW ; NSTRUCT 変数を確保
st->Number = 100
mes "Number=" + st->Number