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

HidP_InitializeReportForID

関数
指定したレポートIDのHIDレポートバッファを初期化する。
DLLHID.dll呼出規約winapi

シグネチャ

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

NTSTATUS HidP_InitializeReportForID(
    HIDP_REPORT_TYPE ReportType,
    BYTE ReportID,
    PHIDP_PREPARSED_DATA PreparsedData,
    LPSTR Report,
    DWORD ReportLength
);

パラメーター

名前方向
ReportTypeHIDP_REPORT_TYPEin
ReportIDBYTEin
PreparsedDataPHIDP_PREPARSED_DATAin
ReportLPSTRout
ReportLengthDWORDin

戻り値の型: NTSTATUS

各言語での呼び出し定義

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

NTSTATUS HidP_InitializeReportForID(
    HIDP_REPORT_TYPE ReportType,
    BYTE ReportID,
    PHIDP_PREPARSED_DATA PreparsedData,
    LPSTR Report,
    DWORD ReportLength
);
[DllImport("HID.dll", ExactSpelling = true)]
static extern int HidP_InitializeReportForID(
    int ReportType,   // HIDP_REPORT_TYPE
    byte ReportID,   // BYTE
    IntPtr PreparsedData,   // PHIDP_PREPARSED_DATA
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder Report,   // LPSTR out
    uint ReportLength   // DWORD
);
<DllImport("HID.dll", ExactSpelling:=True)>
Public Shared Function HidP_InitializeReportForID(
    ReportType As Integer,   ' HIDP_REPORT_TYPE
    ReportID As Byte,   ' BYTE
    PreparsedData As IntPtr,   ' PHIDP_PREPARSED_DATA
    <MarshalAs(UnmanagedType.LPStr)> Report As System.Text.StringBuilder,   ' LPSTR out
    ReportLength As UInteger   ' DWORD
) As Integer
End Function
' ReportType : HIDP_REPORT_TYPE
' ReportID : BYTE
' PreparsedData : PHIDP_PREPARSED_DATA
' Report : LPSTR out
' ReportLength : DWORD
Declare PtrSafe Function HidP_InitializeReportForID Lib "hid" ( _
    ByVal ReportType As Long, _
    ByVal ReportID As Byte, _
    ByVal PreparsedData As LongPtr, _
    ByVal Report As String, _
    ByVal ReportLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HidP_InitializeReportForID = ctypes.windll.hid.HidP_InitializeReportForID
HidP_InitializeReportForID.restype = ctypes.c_int
HidP_InitializeReportForID.argtypes = [
    ctypes.c_int,  # ReportType : HIDP_REPORT_TYPE
    ctypes.c_ubyte,  # ReportID : BYTE
    ctypes.c_ssize_t,  # PreparsedData : PHIDP_PREPARSED_DATA
    wintypes.LPSTR,  # Report : LPSTR out
    wintypes.DWORD,  # ReportLength : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('HID.dll')
HidP_InitializeReportForID = Fiddle::Function.new(
  lib['HidP_InitializeReportForID'],
  [
    Fiddle::TYPE_INT,  # ReportType : HIDP_REPORT_TYPE
    -Fiddle::TYPE_CHAR,  # ReportID : BYTE
    Fiddle::TYPE_INTPTR_T,  # PreparsedData : PHIDP_PREPARSED_DATA
    Fiddle::TYPE_VOIDP,  # Report : LPSTR out
    -Fiddle::TYPE_INT,  # ReportLength : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "hid")]
extern "system" {
    fn HidP_InitializeReportForID(
        ReportType: i32,  // HIDP_REPORT_TYPE
        ReportID: u8,  // BYTE
        PreparsedData: isize,  // PHIDP_PREPARSED_DATA
        Report: *mut u8,  // LPSTR out
        ReportLength: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("HID.dll")]
public static extern int HidP_InitializeReportForID(int ReportType, byte ReportID, IntPtr PreparsedData, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder Report, uint ReportLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HID_HidP_InitializeReportForID' -Namespace Win32 -PassThru
# $api::HidP_InitializeReportForID(ReportType, ReportID, PreparsedData, Report, ReportLength)
#uselib "HID.dll"
#func global HidP_InitializeReportForID "HidP_InitializeReportForID" sptr, sptr, sptr, sptr, sptr
; HidP_InitializeReportForID ReportType, ReportID, PreparsedData, varptr(Report), ReportLength   ; 戻り値は stat
; ReportType : HIDP_REPORT_TYPE -> "sptr"
; ReportID : BYTE -> "sptr"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; Report : LPSTR out -> "sptr"
; ReportLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "HID.dll"
#cfunc global HidP_InitializeReportForID "HidP_InitializeReportForID" int, int, sptr, var, int
; res = HidP_InitializeReportForID(ReportType, ReportID, PreparsedData, Report, ReportLength)
; ReportType : HIDP_REPORT_TYPE -> "int"
; ReportID : BYTE -> "int"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; Report : LPSTR out -> "var"
; ReportLength : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; NTSTATUS HidP_InitializeReportForID(HIDP_REPORT_TYPE ReportType, BYTE ReportID, PHIDP_PREPARSED_DATA PreparsedData, LPSTR Report, DWORD ReportLength)
#uselib "HID.dll"
#cfunc global HidP_InitializeReportForID "HidP_InitializeReportForID" int, int, intptr, var, int
; res = HidP_InitializeReportForID(ReportType, ReportID, PreparsedData, Report, ReportLength)
; ReportType : HIDP_REPORT_TYPE -> "int"
; ReportID : BYTE -> "int"
; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr"
; Report : LPSTR out -> "var"
; ReportLength : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	hid = windows.NewLazySystemDLL("HID.dll")
	procHidP_InitializeReportForID = hid.NewProc("HidP_InitializeReportForID")
)

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