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

HidP_MaxUsageListLength

関数
HIDレポートが返しうる用途リストの最大長を取得する。
DLLHID.dll呼出規約winapi

シグネチャ

// HID.dll
#include <windows.h>

DWORD HidP_MaxUsageListLength(
    HIDP_REPORT_TYPE ReportType,
    WORD UsagePage,   // optional
    PHIDP_PREPARSED_DATA PreparsedData
);

パラメーター

名前方向
ReportTypeHIDP_REPORT_TYPEin
UsagePageWORDinoptional
PreparsedDataPHIDP_PREPARSED_DATAin

戻り値の型: DWORD

各言語での呼び出し定義

// HID.dll
#include <windows.h>

DWORD HidP_MaxUsageListLength(
    HIDP_REPORT_TYPE ReportType,
    WORD UsagePage,   // optional
    PHIDP_PREPARSED_DATA PreparsedData
);
[DllImport("HID.dll", ExactSpelling = true)]
static extern uint HidP_MaxUsageListLength(
    int ReportType,   // HIDP_REPORT_TYPE
    ushort UsagePage,   // WORD optional
    IntPtr PreparsedData   // PHIDP_PREPARSED_DATA
);
<DllImport("HID.dll", ExactSpelling:=True)>
Public Shared Function HidP_MaxUsageListLength(
    ReportType As Integer,   ' HIDP_REPORT_TYPE
    UsagePage As UShort,   ' WORD optional
    PreparsedData As IntPtr   ' PHIDP_PREPARSED_DATA
) As UInteger
End Function
' ReportType : HIDP_REPORT_TYPE
' UsagePage : WORD optional
' PreparsedData : PHIDP_PREPARSED_DATA
Declare PtrSafe Function HidP_MaxUsageListLength Lib "hid" ( _
    ByVal ReportType As Long, _
    ByVal UsagePage As Integer, _
    ByVal PreparsedData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HidP_MaxUsageListLength = ctypes.windll.hid.HidP_MaxUsageListLength
HidP_MaxUsageListLength.restype = wintypes.DWORD
HidP_MaxUsageListLength.argtypes = [
    ctypes.c_int,  # ReportType : HIDP_REPORT_TYPE
    ctypes.c_ushort,  # UsagePage : WORD optional
    ctypes.c_ssize_t,  # PreparsedData : PHIDP_PREPARSED_DATA
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('HID.dll')
HidP_MaxUsageListLength = Fiddle::Function.new(
  lib['HidP_MaxUsageListLength'],
  [
    Fiddle::TYPE_INT,  # ReportType : HIDP_REPORT_TYPE
    -Fiddle::TYPE_SHORT,  # UsagePage : WORD optional
    Fiddle::TYPE_INTPTR_T,  # PreparsedData : PHIDP_PREPARSED_DATA
  ],
  -Fiddle::TYPE_INT)
#[link(name = "hid")]
extern "system" {
    fn HidP_MaxUsageListLength(
        ReportType: i32,  // HIDP_REPORT_TYPE
        UsagePage: u16,  // WORD optional
        PreparsedData: isize  // PHIDP_PREPARSED_DATA
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("HID.dll")]
public static extern uint HidP_MaxUsageListLength(int ReportType, ushort UsagePage, IntPtr PreparsedData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HID_HidP_MaxUsageListLength' -Namespace Win32 -PassThru
# $api::HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
#uselib "HID.dll"
#func global HidP_MaxUsageListLength "HidP_MaxUsageListLength" sptr, sptr, sptr
; HidP_MaxUsageListLength ReportType, UsagePage, PreparsedData   ; 戻り値は stat
; ReportType : HIDP_REPORT_TYPE -> "sptr"
; UsagePage : WORD optional -> "sptr"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "HID.dll"
#cfunc global HidP_MaxUsageListLength "HidP_MaxUsageListLength" int, int, sptr
; res = HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
; ReportType : HIDP_REPORT_TYPE -> "int"
; UsagePage : WORD optional -> "int"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; DWORD HidP_MaxUsageListLength(HIDP_REPORT_TYPE ReportType, WORD UsagePage, PHIDP_PREPARSED_DATA PreparsedData)
#uselib "HID.dll"
#cfunc global HidP_MaxUsageListLength "HidP_MaxUsageListLength" int, int, intptr
; res = HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
; ReportType : HIDP_REPORT_TYPE -> "int"
; UsagePage : WORD optional -> "int"
; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	hid = windows.NewLazySystemDLL("HID.dll")
	procHidP_MaxUsageListLength = hid.NewProc("HidP_MaxUsageListLength")
)

// ReportType (HIDP_REPORT_TYPE), UsagePage (WORD optional), PreparsedData (PHIDP_PREPARSED_DATA)
r1, _, err := procHidP_MaxUsageListLength.Call(
	uintptr(ReportType),
	uintptr(UsagePage),
	uintptr(PreparsedData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function HidP_MaxUsageListLength(
  ReportType: Integer;   // HIDP_REPORT_TYPE
  UsagePage: Word;   // WORD optional
  PreparsedData: NativeInt   // PHIDP_PREPARSED_DATA
): DWORD; stdcall;
  external 'HID.dll' name 'HidP_MaxUsageListLength';
result := DllCall("HID\HidP_MaxUsageListLength"
    , "Int", ReportType   ; HIDP_REPORT_TYPE
    , "UShort", UsagePage   ; WORD optional
    , "Ptr", PreparsedData   ; PHIDP_PREPARSED_DATA
    , "UInt")   ; return: DWORD
●HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData) = DLL("HID.dll", "dword HidP_MaxUsageListLength(int, int, int)")
# 呼び出し: HidP_MaxUsageListLength(ReportType, UsagePage, PreparsedData)
# ReportType : HIDP_REPORT_TYPE -> "int"
# UsagePage : WORD optional -> "int"
# PreparsedData : PHIDP_PREPARSED_DATA -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。