ホーム › Devices.HumanInterfaceDevice › DIDEVICEINSTANCEW
DIDEVICEINSTANCEW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwSize | DWORD | 4 | +0 | +0 | この構造体のバイトサイズ。 |
| guidInstance | GUID | 16 | +4 | +4 | デバイスインスタンスを一意に識別するGUID。 |
| guidProduct | GUID | 16 | +20 | +20 | デバイス製品を識別するGUID。 |
| dwDevType | DWORD | 4 | +36 | +36 | デバイス種別を示す値。 |
| tszInstanceName | WCHAR | 520 | +40 | +40 | デバイスインスタンス名を示すワイド文字列。 |
| tszProductName | WCHAR | 520 | +560 | +560 | デバイス製品名を示すワイド文字列。 |
| guidFFDriver | GUID | 16 | +1080 | +1080 | フォースフィードバックドライバーを識別するGUID。 |
| wUsagePage | WORD | 2 | +1096 | +1096 | HIDのUsage Page値。 |
| wUsage | WORD | 2 | +1098 | +1098 | HIDの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 Structureimport 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: uint16struct 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