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

NVME_SCSI_NAME_STRING

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

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

フィールド

フィールドサイズx64x86説明
PCIVendorIDCHAR4+0+0SCSI名前文字列を構成するPCIベンダーID部分の文字配列である。
ModelNumberCHAR40+4+4SCSI名前文字列を構成するモデル番号部分の文字配列である。
NamespaceIDCHAR4+44+44SCSI名前文字列を構成する名前空間ID部分の文字配列である。
SerialNumberCHAR20+48+48SCSI名前文字列を構成するシリアル番号部分の文字配列である。

各言語での定義

#include <windows.h>

// NVME_SCSI_NAME_STRING  (x64 68 / x86 68 バイト)
typedef struct NVME_SCSI_NAME_STRING {
    CHAR PCIVendorID[4];
    CHAR ModelNumber[40];
    CHAR NamespaceID[4];
    CHAR SerialNumber[20];
} NVME_SCSI_NAME_STRING;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NVME_SCSI_NAME_STRING
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public sbyte[] PCIVendorID;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)] public sbyte[] ModelNumber;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public sbyte[] NamespaceID;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] public sbyte[] SerialNumber;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NVME_SCSI_NAME_STRING
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public PCIVendorID() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=40)> Public ModelNumber() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public NamespaceID() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=20)> Public SerialNumber() As SByte
End Structure
import ctypes
from ctypes import wintypes

class NVME_SCSI_NAME_STRING(ctypes.Structure):
    _fields_ = [
        ("PCIVendorID", ctypes.c_byte * 4),
        ("ModelNumber", ctypes.c_byte * 40),
        ("NamespaceID", ctypes.c_byte * 4),
        ("SerialNumber", ctypes.c_byte * 20),
    ]
#[repr(C)]
pub struct NVME_SCSI_NAME_STRING {
    pub PCIVendorID: [i8; 4],
    pub ModelNumber: [i8; 40],
    pub NamespaceID: [i8; 4],
    pub SerialNumber: [i8; 20],
}
import "golang.org/x/sys/windows"

type NVME_SCSI_NAME_STRING struct {
	PCIVendorID [4]int8
	ModelNumber [40]int8
	NamespaceID [4]int8
	SerialNumber [20]int8
}
type
  NVME_SCSI_NAME_STRING = record
    PCIVendorID: array[0..3] of Shortint;
    ModelNumber: array[0..39] of Shortint;
    NamespaceID: array[0..3] of Shortint;
    SerialNumber: array[0..19] of Shortint;
  end;
const NVME_SCSI_NAME_STRING = extern struct {
    PCIVendorID: [4]i8,
    ModelNumber: [40]i8,
    NamespaceID: [4]i8,
    SerialNumber: [20]i8,
};
type
  NVME_SCSI_NAME_STRING {.bycopy.} = object
    PCIVendorID: array[4, int8]
    ModelNumber: array[40, int8]
    NamespaceID: array[4, int8]
    SerialNumber: array[20, int8]
struct NVME_SCSI_NAME_STRING
{
    byte[4] PCIVendorID;
    byte[40] ModelNumber;
    byte[4] NamespaceID;
    byte[20] SerialNumber;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NVME_SCSI_NAME_STRING サイズ: 68 バイト(x64)
dim st, 17    ; 4byte整数×17(構造体サイズ 68 / 4 切り上げ)
; PCIVendorID : CHAR (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; ModelNumber : CHAR (+4, 40byte)  varptr(st)+4 を基点に操作(40byte:入れ子/配列)
; NamespaceID : CHAR (+44, 4byte)  varptr(st)+44 を基点に操作(4byte:入れ子/配列)
; SerialNumber : CHAR (+48, 20byte)  varptr(st)+48 を基点に操作(20byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NVME_SCSI_NAME_STRING
    #field byte PCIVendorID 4
    #field byte ModelNumber 40
    #field byte NamespaceID 4
    #field byte SerialNumber 20
#endstruct

stdim st, NVME_SCSI_NAME_STRING        ; NSTRUCT 変数を確保