Win32 API 日本語リファレンス
ホームDevices.HumanInterfaceDevice › DIDEVICEINSTANCEW

DIDEVICEINSTANCEW

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

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

フィールド

フィールドサイズx64x86説明
dwSizeDWORD4+0+0この構造体のバイトサイズ。
guidInstanceGUID16+4+4デバイスインスタンスを一意に識別するGUID。
guidProductGUID16+20+20デバイス製品を識別するGUID。
dwDevTypeDWORD4+36+36デバイス種別を示す値。
tszInstanceNameWCHAR520+40+40デバイスインスタンス名を示すワイド文字列。
tszProductNameWCHAR520+560+560デバイス製品名を示すワイド文字列。
guidFFDriverGUID16+1080+1080フォースフィードバックドライバーを識別するGUID。
wUsagePageWORD2+1096+1096HIDのUsage Page値。
wUsageWORD2+1098+1098HIDのUsage値。

各言語での定義

#include <windows.h>

// DIDEVICEINSTANCEW  (x64 1100 / x86 1100 バイト)
typedef struct DIDEVICEINSTANCEW {
    DWORD dwSize;
    GUID guidInstance;
    GUID guidProduct;
    DWORD dwDevType;
    WCHAR tszInstanceName[260];
    WCHAR tszProductName[260];
    GUID guidFFDriver;
    WORD wUsagePage;
    WORD wUsage;
} DIDEVICEINSTANCEW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DIDEVICEINSTANCEW
{
    public uint dwSize;
    public Guid guidInstance;
    public Guid guidProduct;
    public uint dwDevType;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string tszInstanceName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string tszProductName;
    public Guid guidFFDriver;
    public ushort wUsagePage;
    public ushort wUsage;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DIDEVICEINSTANCEW
    Public dwSize As UInteger
    Public guidInstance As Guid
    Public guidProduct As Guid
    Public dwDevType As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public tszInstanceName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public tszProductName As String
    Public guidFFDriver As Guid
    Public wUsagePage As UShort
    Public wUsage As UShort
End Structure
import ctypes
from ctypes import wintypes

class DIDEVICEINSTANCEW(ctypes.Structure):
    _fields_ = [
        ("dwSize", wintypes.DWORD),
        ("guidInstance", GUID),
        ("guidProduct", GUID),
        ("dwDevType", wintypes.DWORD),
        ("tszInstanceName", ctypes.c_wchar * 260),
        ("tszProductName", ctypes.c_wchar * 260),
        ("guidFFDriver", GUID),
        ("wUsagePage", ctypes.c_ushort),
        ("wUsage", ctypes.c_ushort),
    ]
#[repr(C)]
pub struct DIDEVICEINSTANCEW {
    pub dwSize: u32,
    pub guidInstance: GUID,
    pub guidProduct: GUID,
    pub dwDevType: u32,
    pub tszInstanceName: [u16; 260],
    pub tszProductName: [u16; 260],
    pub guidFFDriver: GUID,
    pub wUsagePage: u16,
    pub wUsage: u16,
}
import "golang.org/x/sys/windows"

type DIDEVICEINSTANCEW struct {
	dwSize uint32
	guidInstance windows.GUID
	guidProduct windows.GUID
	dwDevType uint32
	tszInstanceName [260]uint16
	tszProductName [260]uint16
	guidFFDriver windows.GUID
	wUsagePage uint16
	wUsage uint16
}
type
  DIDEVICEINSTANCEW = record
    dwSize: DWORD;
    guidInstance: TGUID;
    guidProduct: TGUID;
    dwDevType: DWORD;
    tszInstanceName: array[0..259] of WideChar;
    tszProductName: array[0..259] of WideChar;
    guidFFDriver: TGUID;
    wUsagePage: Word;
    wUsage: Word;
  end;
const DIDEVICEINSTANCEW = extern struct {
    dwSize: u32,
    guidInstance: GUID,
    guidProduct: GUID,
    dwDevType: u32,
    tszInstanceName: [260]u16,
    tszProductName: [260]u16,
    guidFFDriver: GUID,
    wUsagePage: u16,
    wUsage: u16,
};
type
  DIDEVICEINSTANCEW {.bycopy.} = object
    dwSize: uint32
    guidInstance: GUID
    guidProduct: GUID
    dwDevType: uint32
    tszInstanceName: array[260, uint16]
    tszProductName: array[260, uint16]
    guidFFDriver: GUID
    wUsagePage: uint16
    wUsage: uint16
struct DIDEVICEINSTANCEW
{
    uint dwSize;
    GUID guidInstance;
    GUID guidProduct;
    uint dwDevType;
    wchar[260] tszInstanceName;
    wchar[260] tszProductName;
    GUID guidFFDriver;
    ushort wUsagePage;
    ushort wUsage;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DIDEVICEINSTANCEW サイズ: 1100 バイト(x64)
dim st, 275    ; 4byte整数×275(構造体サイズ 1100 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; guidInstance : GUID (+4, 16byte)  varptr(st)+4 を基点に操作(16byte:入れ子/配列)
; guidProduct : GUID (+20, 16byte)  varptr(st)+20 を基点に操作(16byte:入れ子/配列)
; dwDevType : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; tszInstanceName : WCHAR (+40, 520byte)  varptr(st)+40 を基点に操作(520byte:入れ子/配列)
; tszProductName : WCHAR (+560, 520byte)  varptr(st)+560 を基点に操作(520byte:入れ子/配列)
; guidFFDriver : GUID (+1080, 16byte)  varptr(st)+1080 を基点に操作(16byte:入れ子/配列)
; wUsagePage : WORD (+1096, 2byte)  wpoke st,1096,値  /  値 = wpeek(st,1096)
; wUsage : WORD (+1098, 2byte)  wpoke st,1098,値  /  値 = wpeek(st,1098)
; ※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 DIDEVICEINSTANCEW
    #field int dwSize
    #field GUID guidInstance
    #field GUID guidProduct
    #field int dwDevType
    #field wchar tszInstanceName 260
    #field wchar tszProductName 260
    #field GUID guidFFDriver
    #field short wUsagePage
    #field short wUsage
#endstruct

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