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

NTMS_DRIVEINFORMATIONA

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

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

フィールド

フィールドサイズx64x86説明
NumberDWORD4+0+0ライブラリ内のドライブ番号。
StateDWORD4+4+4ドライブの現在の状態を示す値。
DriveTypeGUID16+8+8ドライブ種別を識別するGUID。
szDeviceNameCHAR64+24+24デバイス名を格納するANSI文字配列。
szSerialNumberCHAR32+88+88ドライブのシリアル番号を格納するANSI文字配列。
szRevisionCHAR32+120+120ドライブのリビジョン文字列。ANSI。
ScsiPortWORD2+152+152ドライブが接続されたSCSIポート番号。
ScsiBusWORD2+154+154ドライブのSCSIバス番号。
ScsiTargetWORD2+156+156ドライブのSCSIターゲットID。
ScsiLunWORD2+158+158ドライブのSCSI論理ユニット番号。
dwMountCountDWORD4+160+160ドライブのマウント累計回数。
LastCleanedTsSYSTEMTIME16+164+164最後にクリーニングした日時。SYSTEMTIME。
SavedPartitionIdGUID16+180+180保存されたパーティションを識別するGUID。
LibraryGUID16+196+196ドライブが属するライブラリのGUID。
ReservedGUID16+212+212予約フィールド。GUID形式。
dwDeferDismountDelayDWORD4+228+228ディスマウントを延期する遅延時間。秒単位。

各言語での定義

#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_DRIVEINFORMATIONA  (x64 232 / x86 232 バイト)
typedef struct NTMS_DRIVEINFORMATIONA {
    DWORD Number;
    DWORD State;
    GUID DriveType;
    CHAR szDeviceName[64];
    CHAR szSerialNumber[32];
    CHAR szRevision[32];
    WORD ScsiPort;
    WORD ScsiBus;
    WORD ScsiTarget;
    WORD ScsiLun;
    DWORD dwMountCount;
    SYSTEMTIME LastCleanedTs;
    GUID SavedPartitionId;
    GUID Library;
    GUID Reserved;
    DWORD dwDeferDismountDelay;
} NTMS_DRIVEINFORMATIONA;
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_DRIVEINFORMATIONA
{
    public uint Number;
    public uint State;
    public Guid DriveType;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] public sbyte[] szDeviceName;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public sbyte[] szSerialNumber;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public sbyte[] 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_DRIVEINFORMATIONA
    Public Number As UInteger
    Public State As UInteger
    Public DriveType As Guid
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=64)> Public szDeviceName() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> Public szSerialNumber() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> Public szRevision() As SByte
    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 Structure
import 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_DRIVEINFORMATIONA(ctypes.Structure):
    _fields_ = [
        ("Number", wintypes.DWORD),
        ("State", wintypes.DWORD),
        ("DriveType", GUID),
        ("szDeviceName", ctypes.c_byte * 64),
        ("szSerialNumber", ctypes.c_byte * 32),
        ("szRevision", ctypes.c_byte * 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_DRIVEINFORMATIONA {
    pub Number: u32,
    pub State: u32,
    pub DriveType: GUID,
    pub szDeviceName: [i8; 64],
    pub szSerialNumber: [i8; 32],
    pub szRevision: [i8; 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_DRIVEINFORMATIONA struct {
	Number uint32
	State uint32
	DriveType windows.GUID
	szDeviceName [64]int8
	szSerialNumber [32]int8
	szRevision [32]int8
	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_DRIVEINFORMATIONA = record
    Number: DWORD;
    State: DWORD;
    DriveType: TGUID;
    szDeviceName: array[0..63] of Shortint;
    szSerialNumber: array[0..31] of Shortint;
    szRevision: array[0..31] of Shortint;
    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_DRIVEINFORMATIONA = extern struct {
    Number: u32,
    State: u32,
    DriveType: GUID,
    szDeviceName: [64]i8,
    szSerialNumber: [32]i8,
    szRevision: [32]i8,
    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_DRIVEINFORMATIONA {.bycopy.} = object
    Number: uint32
    State: uint32
    DriveType: GUID
    szDeviceName: array[64, int8]
    szSerialNumber: array[32, int8]
    szRevision: array[32, int8]
    ScsiPort: uint16
    ScsiBus: uint16
    ScsiTarget: uint16
    ScsiLun: uint16
    dwMountCount: uint32
    LastCleanedTs: SYSTEMTIME
    SavedPartitionId: GUID
    Library: GUID
    Reserved: GUID
    dwDeferDismountDelay: uint32
struct SYSTEMTIME
{
    ushort wYear;
    ushort wMonth;
    ushort wDayOfWeek;
    ushort wDay;
    ushort wHour;
    ushort wMinute;
    ushort wSecond;
    ushort wMilliseconds;
}

struct NTMS_DRIVEINFORMATIONA
{
    uint Number;
    uint State;
    GUID DriveType;
    byte[64] szDeviceName;
    byte[32] szSerialNumber;
    byte[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_DRIVEINFORMATIONA サイズ: 232 バイト(x64)
dim st, 58    ; 4byte整数×58(構造体サイズ 232 / 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 : CHAR (+24, 64byte)  varptr(st)+24 を基点に操作(64byte:入れ子/配列)
; szSerialNumber : CHAR (+88, 32byte)  varptr(st)+88 を基点に操作(32byte:入れ子/配列)
; szRevision : CHAR (+120, 32byte)  varptr(st)+120 を基点に操作(32byte:入れ子/配列)
; ScsiPort : WORD (+152, 2byte)  wpoke st,152,値  /  値 = wpeek(st,152)
; ScsiBus : WORD (+154, 2byte)  wpoke st,154,値  /  値 = wpeek(st,154)
; ScsiTarget : WORD (+156, 2byte)  wpoke st,156,値  /  値 = wpeek(st,156)
; ScsiLun : WORD (+158, 2byte)  wpoke st,158,値  /  値 = wpeek(st,158)
; dwMountCount : DWORD (+160, 4byte)  st.40 = 値  /  値 = st.40   (lpoke/lpeek も可)
; LastCleanedTs : SYSTEMTIME (+164, 16byte)  varptr(st)+164 を基点に操作(16byte:入れ子/配列)
; SavedPartitionId : GUID (+180, 16byte)  varptr(st)+180 を基点に操作(16byte:入れ子/配列)
; Library : GUID (+196, 16byte)  varptr(st)+196 を基点に操作(16byte:入れ子/配列)
; Reserved : GUID (+212, 16byte)  varptr(st)+212 を基点に操作(16byte:入れ子/配列)
; dwDeferDismountDelay : DWORD (+228, 4byte)  st.57 = 値  /  値 = st.57   (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_DRIVEINFORMATIONA
    #field int Number
    #field int State
    #field GUID DriveType
    #field byte szDeviceName 64
    #field byte szSerialNumber 32
    #field byte 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_DRIVEINFORMATIONA        ; NSTRUCT 変数を確保
st->Number = 100
mes "Number=" + st->Number