ホーム › Devices.HumanInterfaceDevice › HidP_GetExtendedAttributes
HidP_GetExtendedAttributes
関数指定したHID値コントロールの拡張属性を取得する。
シグネチャ
// HID.dll
#include <windows.h>
NTSTATUS HidP_GetExtendedAttributes(
HIDP_REPORT_TYPE ReportType,
WORD DataIndex,
PHIDP_PREPARSED_DATA PreparsedData,
HIDP_EXTENDED_ATTRIBUTES* Attributes,
DWORD* LengthAttributes
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ReportType | HIDP_REPORT_TYPE | in |
| DataIndex | WORD | in |
| PreparsedData | PHIDP_PREPARSED_DATA | in |
| Attributes | HIDP_EXTENDED_ATTRIBUTES* | out |
| LengthAttributes | DWORD* | inout |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// HID.dll
#include <windows.h>
NTSTATUS HidP_GetExtendedAttributes(
HIDP_REPORT_TYPE ReportType,
WORD DataIndex,
PHIDP_PREPARSED_DATA PreparsedData,
HIDP_EXTENDED_ATTRIBUTES* Attributes,
DWORD* LengthAttributes
);[DllImport("HID.dll", ExactSpelling = true)]
static extern int HidP_GetExtendedAttributes(
int ReportType, // HIDP_REPORT_TYPE
ushort DataIndex, // WORD
IntPtr PreparsedData, // PHIDP_PREPARSED_DATA
IntPtr Attributes, // HIDP_EXTENDED_ATTRIBUTES* out
ref uint LengthAttributes // DWORD* in/out
);<DllImport("HID.dll", ExactSpelling:=True)>
Public Shared Function HidP_GetExtendedAttributes(
ReportType As Integer, ' HIDP_REPORT_TYPE
DataIndex As UShort, ' WORD
PreparsedData As IntPtr, ' PHIDP_PREPARSED_DATA
Attributes As IntPtr, ' HIDP_EXTENDED_ATTRIBUTES* out
ByRef LengthAttributes As UInteger ' DWORD* in/out
) As Integer
End Function' ReportType : HIDP_REPORT_TYPE
' DataIndex : WORD
' PreparsedData : PHIDP_PREPARSED_DATA
' Attributes : HIDP_EXTENDED_ATTRIBUTES* out
' LengthAttributes : DWORD* in/out
Declare PtrSafe Function HidP_GetExtendedAttributes Lib "hid" ( _
ByVal ReportType As Long, _
ByVal DataIndex As Integer, _
ByVal PreparsedData As LongPtr, _
ByVal Attributes As LongPtr, _
ByRef LengthAttributes As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HidP_GetExtendedAttributes = ctypes.windll.hid.HidP_GetExtendedAttributes
HidP_GetExtendedAttributes.restype = ctypes.c_int
HidP_GetExtendedAttributes.argtypes = [
ctypes.c_int, # ReportType : HIDP_REPORT_TYPE
ctypes.c_ushort, # DataIndex : WORD
ctypes.c_ssize_t, # PreparsedData : PHIDP_PREPARSED_DATA
ctypes.c_void_p, # Attributes : HIDP_EXTENDED_ATTRIBUTES* out
ctypes.POINTER(wintypes.DWORD), # LengthAttributes : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('HID.dll')
HidP_GetExtendedAttributes = Fiddle::Function.new(
lib['HidP_GetExtendedAttributes'],
[
Fiddle::TYPE_INT, # ReportType : HIDP_REPORT_TYPE
-Fiddle::TYPE_SHORT, # DataIndex : WORD
Fiddle::TYPE_INTPTR_T, # PreparsedData : PHIDP_PREPARSED_DATA
Fiddle::TYPE_VOIDP, # Attributes : HIDP_EXTENDED_ATTRIBUTES* out
Fiddle::TYPE_VOIDP, # LengthAttributes : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "hid")]
extern "system" {
fn HidP_GetExtendedAttributes(
ReportType: i32, // HIDP_REPORT_TYPE
DataIndex: u16, // WORD
PreparsedData: isize, // PHIDP_PREPARSED_DATA
Attributes: *mut HIDP_EXTENDED_ATTRIBUTES, // HIDP_EXTENDED_ATTRIBUTES* out
LengthAttributes: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("HID.dll")]
public static extern int HidP_GetExtendedAttributes(int ReportType, ushort DataIndex, IntPtr PreparsedData, IntPtr Attributes, ref uint LengthAttributes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HID_HidP_GetExtendedAttributes' -Namespace Win32 -PassThru
# $api::HidP_GetExtendedAttributes(ReportType, DataIndex, PreparsedData, Attributes, LengthAttributes)#uselib "HID.dll"
#func global HidP_GetExtendedAttributes "HidP_GetExtendedAttributes" sptr, sptr, sptr, sptr, sptr
; HidP_GetExtendedAttributes ReportType, DataIndex, PreparsedData, varptr(Attributes), varptr(LengthAttributes) ; 戻り値は stat
; ReportType : HIDP_REPORT_TYPE -> "sptr"
; DataIndex : WORD -> "sptr"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; Attributes : HIDP_EXTENDED_ATTRIBUTES* out -> "sptr"
; LengthAttributes : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "HID.dll" #cfunc global HidP_GetExtendedAttributes "HidP_GetExtendedAttributes" int, int, sptr, var, var ; res = HidP_GetExtendedAttributes(ReportType, DataIndex, PreparsedData, Attributes, LengthAttributes) ; ReportType : HIDP_REPORT_TYPE -> "int" ; DataIndex : WORD -> "int" ; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr" ; Attributes : HIDP_EXTENDED_ATTRIBUTES* out -> "var" ; LengthAttributes : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "HID.dll" #cfunc global HidP_GetExtendedAttributes "HidP_GetExtendedAttributes" int, int, sptr, sptr, sptr ; res = HidP_GetExtendedAttributes(ReportType, DataIndex, PreparsedData, varptr(Attributes), varptr(LengthAttributes)) ; ReportType : HIDP_REPORT_TYPE -> "int" ; DataIndex : WORD -> "int" ; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr" ; Attributes : HIDP_EXTENDED_ATTRIBUTES* out -> "sptr" ; LengthAttributes : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS HidP_GetExtendedAttributes(HIDP_REPORT_TYPE ReportType, WORD DataIndex, PHIDP_PREPARSED_DATA PreparsedData, HIDP_EXTENDED_ATTRIBUTES* Attributes, DWORD* LengthAttributes) #uselib "HID.dll" #cfunc global HidP_GetExtendedAttributes "HidP_GetExtendedAttributes" int, int, intptr, var, var ; res = HidP_GetExtendedAttributes(ReportType, DataIndex, PreparsedData, Attributes, LengthAttributes) ; ReportType : HIDP_REPORT_TYPE -> "int" ; DataIndex : WORD -> "int" ; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr" ; Attributes : HIDP_EXTENDED_ATTRIBUTES* out -> "var" ; LengthAttributes : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS HidP_GetExtendedAttributes(HIDP_REPORT_TYPE ReportType, WORD DataIndex, PHIDP_PREPARSED_DATA PreparsedData, HIDP_EXTENDED_ATTRIBUTES* Attributes, DWORD* LengthAttributes) #uselib "HID.dll" #cfunc global HidP_GetExtendedAttributes "HidP_GetExtendedAttributes" int, int, intptr, intptr, intptr ; res = HidP_GetExtendedAttributes(ReportType, DataIndex, PreparsedData, varptr(Attributes), varptr(LengthAttributes)) ; ReportType : HIDP_REPORT_TYPE -> "int" ; DataIndex : WORD -> "int" ; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr" ; Attributes : HIDP_EXTENDED_ATTRIBUTES* out -> "intptr" ; LengthAttributes : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
hid = windows.NewLazySystemDLL("HID.dll")
procHidP_GetExtendedAttributes = hid.NewProc("HidP_GetExtendedAttributes")
)
// ReportType (HIDP_REPORT_TYPE), DataIndex (WORD), PreparsedData (PHIDP_PREPARSED_DATA), Attributes (HIDP_EXTENDED_ATTRIBUTES* out), LengthAttributes (DWORD* in/out)
r1, _, err := procHidP_GetExtendedAttributes.Call(
uintptr(ReportType),
uintptr(DataIndex),
uintptr(PreparsedData),
uintptr(Attributes),
uintptr(LengthAttributes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction HidP_GetExtendedAttributes(
ReportType: Integer; // HIDP_REPORT_TYPE
DataIndex: Word; // WORD
PreparsedData: NativeInt; // PHIDP_PREPARSED_DATA
Attributes: Pointer; // HIDP_EXTENDED_ATTRIBUTES* out
LengthAttributes: Pointer // DWORD* in/out
): Integer; stdcall;
external 'HID.dll' name 'HidP_GetExtendedAttributes';result := DllCall("HID\HidP_GetExtendedAttributes"
, "Int", ReportType ; HIDP_REPORT_TYPE
, "UShort", DataIndex ; WORD
, "Ptr", PreparsedData ; PHIDP_PREPARSED_DATA
, "Ptr", Attributes ; HIDP_EXTENDED_ATTRIBUTES* out
, "Ptr", LengthAttributes ; DWORD* in/out
, "Int") ; return: NTSTATUS●HidP_GetExtendedAttributes(ReportType, DataIndex, PreparsedData, Attributes, LengthAttributes) = DLL("HID.dll", "int HidP_GetExtendedAttributes(int, int, int, void*, void*)")
# 呼び出し: HidP_GetExtendedAttributes(ReportType, DataIndex, PreparsedData, Attributes, LengthAttributes)
# ReportType : HIDP_REPORT_TYPE -> "int"
# DataIndex : WORD -> "int"
# PreparsedData : PHIDP_PREPARSED_DATA -> "int"
# Attributes : HIDP_EXTENDED_ATTRIBUTES* out -> "void*"
# LengthAttributes : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。