ホーム › Devices.HumanInterfaceDevice › HID_COLLECTION_INFORMATION
HID_COLLECTION_INFORMATION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| DescriptorSize | DWORD | 4 | +0 | +0 | プリパースデータ(レポート記述子)のバイトサイズ。 |
| Polled | BOOLEAN | 1 | +4 | +4 | デバイスがポーリング方式かを示す真偽値。 |
| Reserved1 | BYTE | 1 | +5 | +5 | 予約フィールド。使用しない。 |
| VendorID | WORD | 2 | +6 | +6 | デバイスのベンダーID(VID)。 |
| ProductID | WORD | 2 | +8 | +8 | デバイスの製品ID(PID)。 |
| VersionNumber | WORD | 2 | +10 | +10 | デバイスのバージョン番号。 |
各言語での定義
#include <windows.h>
// HID_COLLECTION_INFORMATION (x64 12 / x86 12 バイト)
typedef struct HID_COLLECTION_INFORMATION {
DWORD DescriptorSize;
BOOLEAN Polled;
BYTE Reserved1[1];
WORD VendorID;
WORD ProductID;
WORD VersionNumber;
} HID_COLLECTION_INFORMATION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HID_COLLECTION_INFORMATION
{
public uint DescriptorSize;
[MarshalAs(UnmanagedType.U1)] public bool Polled;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public byte[] Reserved1;
public ushort VendorID;
public ushort ProductID;
public ushort VersionNumber;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure HID_COLLECTION_INFORMATION
Public DescriptorSize As UInteger
<MarshalAs(UnmanagedType.U1)> Public Polled As Boolean
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Reserved1() As Byte
Public VendorID As UShort
Public ProductID As UShort
Public VersionNumber As UShort
End Structureimport ctypes
from ctypes import wintypes
class HID_COLLECTION_INFORMATION(ctypes.Structure):
_fields_ = [
("DescriptorSize", wintypes.DWORD),
("Polled", ctypes.c_byte),
("Reserved1", ctypes.c_ubyte * 1),
("VendorID", ctypes.c_ushort),
("ProductID", ctypes.c_ushort),
("VersionNumber", ctypes.c_ushort),
]#[repr(C)]
pub struct HID_COLLECTION_INFORMATION {
pub DescriptorSize: u32,
pub Polled: u8,
pub Reserved1: [u8; 1],
pub VendorID: u16,
pub ProductID: u16,
pub VersionNumber: u16,
}import "golang.org/x/sys/windows"
type HID_COLLECTION_INFORMATION struct {
DescriptorSize uint32
Polled byte
Reserved1 [1]byte
VendorID uint16
ProductID uint16
VersionNumber uint16
}type
HID_COLLECTION_INFORMATION = record
DescriptorSize: DWORD;
Polled: ByteBool;
Reserved1: array[0..0] of Byte;
VendorID: Word;
ProductID: Word;
VersionNumber: Word;
end;const HID_COLLECTION_INFORMATION = extern struct {
DescriptorSize: u32,
Polled: u8,
Reserved1: [1]u8,
VendorID: u16,
ProductID: u16,
VersionNumber: u16,
};type
HID_COLLECTION_INFORMATION {.bycopy.} = object
DescriptorSize: uint32
Polled: uint8
Reserved1: array[1, uint8]
VendorID: uint16
ProductID: uint16
VersionNumber: uint16struct HID_COLLECTION_INFORMATION
{
uint DescriptorSize;
ubyte Polled;
ubyte[1] Reserved1;
ushort VendorID;
ushort ProductID;
ushort VersionNumber;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; HID_COLLECTION_INFORMATION サイズ: 12 バイト(x64)
dim st, 3 ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; DescriptorSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Polled : BOOLEAN (+4, 1byte) poke st,4,値 / 値 = peek(st,4)
; Reserved1 : BYTE (+5, 1byte) varptr(st)+5 を基点に操作(1byte:入れ子/配列)
; VendorID : WORD (+6, 2byte) wpoke st,6,値 / 値 = wpeek(st,6)
; ProductID : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; VersionNumber : WORD (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global HID_COLLECTION_INFORMATION
#field int DescriptorSize
#field bool1 Polled
#field byte Reserved1 1
#field short VendorID
#field short ProductID
#field short VersionNumber
#endstruct
stdim st, HID_COLLECTION_INFORMATION ; NSTRUCT 変数を確保
st->DescriptorSize = 100
mes "DescriptorSize=" + st->DescriptorSize