Win32 API 日本語リファレンス
ホームDevices.Enumeration.Pnp › SW_DEVICE_CREATE_INFO

SW_DEVICE_CREATE_INFO

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

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

フィールド

フィールドサイズx64x86説明
cbSizeDWORD4+0+0この構造体のサイズをバイト単位で指定するDWORD。バージョン判別に用いる。
pszInstanceIdLPWSTR8/4+8+4ソフトウェアデバイスのインスタンスIDを指すワイド文字列。NULL可。
pszzHardwareIdsLPWSTR8/4+16+8デバイスのハードウェアIDをNUL区切りで連結したマルチ文字列。NULL可。
pszzCompatibleIdsLPWSTR8/4+24+12デバイスの互換IDをNUL区切りで連結したマルチ文字列。NULL可。
pContainerIdGUID*8/4+32+16デバイスを属させるコンテナIDのGUIDへのポインタ。NULL可。
CapabilityFlagsDWORD4+40+20デバイスの能力を示すSW_DEVICE_CAPABILITIESフラグの組み合わせ。
pszDeviceDescriptionLPWSTR8/4+48+24デバイスの説明文字列を指すワイド文字列。NULL可。
pszDeviceLocationLPWSTR8/4+56+28デバイスの位置情報文字列を指すワイド文字列。NULL可。
pSecurityDescriptorSECURITY_DESCRIPTOR*8/4+64+32デバイスに適用するセキュリティ記述子へのポインタ。NULL可。

各言語での定義

#include <windows.h>

// SW_DEVICE_CREATE_INFO  (x64 72 / x86 36 バイト)
typedef struct SW_DEVICE_CREATE_INFO {
    DWORD cbSize;
    LPWSTR pszInstanceId;
    LPWSTR pszzHardwareIds;
    LPWSTR pszzCompatibleIds;
    GUID* pContainerId;
    DWORD CapabilityFlags;
    LPWSTR pszDeviceDescription;
    LPWSTR pszDeviceLocation;
    SECURITY_DESCRIPTOR* pSecurityDescriptor;
} SW_DEVICE_CREATE_INFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SW_DEVICE_CREATE_INFO
{
    public uint cbSize;
    public IntPtr pszInstanceId;
    public IntPtr pszzHardwareIds;
    public IntPtr pszzCompatibleIds;
    public IntPtr pContainerId;
    public uint CapabilityFlags;
    public IntPtr pszDeviceDescription;
    public IntPtr pszDeviceLocation;
    public IntPtr pSecurityDescriptor;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SW_DEVICE_CREATE_INFO
    Public cbSize As UInteger
    Public pszInstanceId As IntPtr
    Public pszzHardwareIds As IntPtr
    Public pszzCompatibleIds As IntPtr
    Public pContainerId As IntPtr
    Public CapabilityFlags As UInteger
    Public pszDeviceDescription As IntPtr
    Public pszDeviceLocation As IntPtr
    Public pSecurityDescriptor As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class SW_DEVICE_CREATE_INFO(ctypes.Structure):
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("pszInstanceId", ctypes.c_void_p),
        ("pszzHardwareIds", ctypes.c_void_p),
        ("pszzCompatibleIds", ctypes.c_void_p),
        ("pContainerId", ctypes.c_void_p),
        ("CapabilityFlags", wintypes.DWORD),
        ("pszDeviceDescription", ctypes.c_void_p),
        ("pszDeviceLocation", ctypes.c_void_p),
        ("pSecurityDescriptor", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct SW_DEVICE_CREATE_INFO {
    pub cbSize: u32,
    pub pszInstanceId: *mut core::ffi::c_void,
    pub pszzHardwareIds: *mut core::ffi::c_void,
    pub pszzCompatibleIds: *mut core::ffi::c_void,
    pub pContainerId: *mut core::ffi::c_void,
    pub CapabilityFlags: u32,
    pub pszDeviceDescription: *mut core::ffi::c_void,
    pub pszDeviceLocation: *mut core::ffi::c_void,
    pub pSecurityDescriptor: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type SW_DEVICE_CREATE_INFO struct {
	cbSize uint32
	pszInstanceId uintptr
	pszzHardwareIds uintptr
	pszzCompatibleIds uintptr
	pContainerId uintptr
	CapabilityFlags uint32
	pszDeviceDescription uintptr
	pszDeviceLocation uintptr
	pSecurityDescriptor uintptr
}
type
  SW_DEVICE_CREATE_INFO = record
    cbSize: DWORD;
    pszInstanceId: Pointer;
    pszzHardwareIds: Pointer;
    pszzCompatibleIds: Pointer;
    pContainerId: Pointer;
    CapabilityFlags: DWORD;
    pszDeviceDescription: Pointer;
    pszDeviceLocation: Pointer;
    pSecurityDescriptor: Pointer;
  end;
const SW_DEVICE_CREATE_INFO = extern struct {
    cbSize: u32,
    pszInstanceId: ?*anyopaque,
    pszzHardwareIds: ?*anyopaque,
    pszzCompatibleIds: ?*anyopaque,
    pContainerId: ?*anyopaque,
    CapabilityFlags: u32,
    pszDeviceDescription: ?*anyopaque,
    pszDeviceLocation: ?*anyopaque,
    pSecurityDescriptor: ?*anyopaque,
};
type
  SW_DEVICE_CREATE_INFO {.bycopy.} = object
    cbSize: uint32
    pszInstanceId: pointer
    pszzHardwareIds: pointer
    pszzCompatibleIds: pointer
    pContainerId: pointer
    CapabilityFlags: uint32
    pszDeviceDescription: pointer
    pszDeviceLocation: pointer
    pSecurityDescriptor: pointer
struct SW_DEVICE_CREATE_INFO
{
    uint cbSize;
    void* pszInstanceId;
    void* pszzHardwareIds;
    void* pszzCompatibleIds;
    void* pContainerId;
    uint CapabilityFlags;
    void* pszDeviceDescription;
    void* pszDeviceLocation;
    void* pSecurityDescriptor;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SW_DEVICE_CREATE_INFO サイズ: 36 バイト(x86)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pszInstanceId : LPWSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; pszzHardwareIds : LPWSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; pszzCompatibleIds : LPWSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; pContainerId : GUID* (+16, 4byte)  varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; CapabilityFlags : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; pszDeviceDescription : LPWSTR (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; pszDeviceLocation : LPWSTR (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; pSecurityDescriptor : SECURITY_DESCRIPTOR* (+32, 4byte)  varptr(st)+32 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SW_DEVICE_CREATE_INFO サイズ: 72 バイト(x64)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pszInstanceId : LPWSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; pszzHardwareIds : LPWSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; pszzCompatibleIds : LPWSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; pContainerId : GUID* (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; CapabilityFlags : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; pszDeviceDescription : LPWSTR (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; pszDeviceLocation : LPWSTR (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; pSecurityDescriptor : SECURITY_DESCRIPTOR* (+64, 8byte)  varptr(st)+64 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SW_DEVICE_CREATE_INFO
    #field int cbSize
    #field intptr pszInstanceId
    #field intptr pszzHardwareIds
    #field intptr pszzCompatibleIds
    #field intptr pContainerId
    #field int CapabilityFlags
    #field intptr pszDeviceDescription
    #field intptr pszDeviceLocation
    #field intptr pSecurityDescriptor
#endstruct

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