GetRawInputDeviceList
関数システムに接続されたRaw Inputデバイス一覧を取得する。
シグネチャ
// USER32.dll
#include <windows.h>
DWORD GetRawInputDeviceList(
RAWINPUTDEVICELIST* pRawInputDeviceList, // optional
DWORD* puiNumDevices,
DWORD cbSize
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pRawInputDeviceList | RAWINPUTDEVICELIST* | outoptional |
| puiNumDevices | DWORD* | inout |
| cbSize | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
DWORD GetRawInputDeviceList(
RAWINPUTDEVICELIST* pRawInputDeviceList, // optional
DWORD* puiNumDevices,
DWORD cbSize
);[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern uint GetRawInputDeviceList(
IntPtr pRawInputDeviceList, // RAWINPUTDEVICELIST* optional, out
ref uint puiNumDevices, // DWORD* in/out
uint cbSize // DWORD
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetRawInputDeviceList(
pRawInputDeviceList As IntPtr, ' RAWINPUTDEVICELIST* optional, out
ByRef puiNumDevices As UInteger, ' DWORD* in/out
cbSize As UInteger ' DWORD
) As UInteger
End Function' pRawInputDeviceList : RAWINPUTDEVICELIST* optional, out
' puiNumDevices : DWORD* in/out
' cbSize : DWORD
Declare PtrSafe Function GetRawInputDeviceList Lib "user32" ( _
ByVal pRawInputDeviceList As LongPtr, _
ByRef puiNumDevices As Long, _
ByVal cbSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetRawInputDeviceList = ctypes.windll.user32.GetRawInputDeviceList
GetRawInputDeviceList.restype = wintypes.DWORD
GetRawInputDeviceList.argtypes = [
ctypes.c_void_p, # pRawInputDeviceList : RAWINPUTDEVICELIST* optional, out
ctypes.POINTER(wintypes.DWORD), # puiNumDevices : DWORD* in/out
wintypes.DWORD, # cbSize : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetRawInputDeviceList = Fiddle::Function.new(
lib['GetRawInputDeviceList'],
[
Fiddle::TYPE_VOIDP, # pRawInputDeviceList : RAWINPUTDEVICELIST* optional, out
Fiddle::TYPE_VOIDP, # puiNumDevices : DWORD* in/out
-Fiddle::TYPE_INT, # cbSize : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetRawInputDeviceList(
pRawInputDeviceList: *mut RAWINPUTDEVICELIST, // RAWINPUTDEVICELIST* optional, out
puiNumDevices: *mut u32, // DWORD* in/out
cbSize: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", SetLastError = true)]
public static extern uint GetRawInputDeviceList(IntPtr pRawInputDeviceList, ref uint puiNumDevices, uint cbSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetRawInputDeviceList' -Namespace Win32 -PassThru
# $api::GetRawInputDeviceList(pRawInputDeviceList, puiNumDevices, cbSize)#uselib "USER32.dll"
#func global GetRawInputDeviceList "GetRawInputDeviceList" sptr, sptr, sptr
; GetRawInputDeviceList varptr(pRawInputDeviceList), varptr(puiNumDevices), cbSize ; 戻り値は stat
; pRawInputDeviceList : RAWINPUTDEVICELIST* optional, out -> "sptr"
; puiNumDevices : DWORD* in/out -> "sptr"
; cbSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global GetRawInputDeviceList "GetRawInputDeviceList" var, var, int ; res = GetRawInputDeviceList(pRawInputDeviceList, puiNumDevices, cbSize) ; pRawInputDeviceList : RAWINPUTDEVICELIST* optional, out -> "var" ; puiNumDevices : DWORD* in/out -> "var" ; cbSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetRawInputDeviceList "GetRawInputDeviceList" sptr, sptr, int ; res = GetRawInputDeviceList(varptr(pRawInputDeviceList), varptr(puiNumDevices), cbSize) ; pRawInputDeviceList : RAWINPUTDEVICELIST* optional, out -> "sptr" ; puiNumDevices : DWORD* in/out -> "sptr" ; cbSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetRawInputDeviceList(RAWINPUTDEVICELIST* pRawInputDeviceList, DWORD* puiNumDevices, DWORD cbSize) #uselib "USER32.dll" #cfunc global GetRawInputDeviceList "GetRawInputDeviceList" var, var, int ; res = GetRawInputDeviceList(pRawInputDeviceList, puiNumDevices, cbSize) ; pRawInputDeviceList : RAWINPUTDEVICELIST* optional, out -> "var" ; puiNumDevices : DWORD* in/out -> "var" ; cbSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetRawInputDeviceList(RAWINPUTDEVICELIST* pRawInputDeviceList, DWORD* puiNumDevices, DWORD cbSize) #uselib "USER32.dll" #cfunc global GetRawInputDeviceList "GetRawInputDeviceList" intptr, intptr, int ; res = GetRawInputDeviceList(varptr(pRawInputDeviceList), varptr(puiNumDevices), cbSize) ; pRawInputDeviceList : RAWINPUTDEVICELIST* optional, out -> "intptr" ; puiNumDevices : DWORD* in/out -> "intptr" ; cbSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetRawInputDeviceList = user32.NewProc("GetRawInputDeviceList")
)
// pRawInputDeviceList (RAWINPUTDEVICELIST* optional, out), puiNumDevices (DWORD* in/out), cbSize (DWORD)
r1, _, err := procGetRawInputDeviceList.Call(
uintptr(pRawInputDeviceList),
uintptr(puiNumDevices),
uintptr(cbSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetRawInputDeviceList(
pRawInputDeviceList: Pointer; // RAWINPUTDEVICELIST* optional, out
puiNumDevices: Pointer; // DWORD* in/out
cbSize: DWORD // DWORD
): DWORD; stdcall;
external 'USER32.dll' name 'GetRawInputDeviceList';result := DllCall("USER32\GetRawInputDeviceList"
, "Ptr", pRawInputDeviceList ; RAWINPUTDEVICELIST* optional, out
, "Ptr", puiNumDevices ; DWORD* in/out
, "UInt", cbSize ; DWORD
, "UInt") ; return: DWORD●GetRawInputDeviceList(pRawInputDeviceList, puiNumDevices, cbSize) = DLL("USER32.dll", "dword GetRawInputDeviceList(void*, void*, dword)")
# 呼び出し: GetRawInputDeviceList(pRawInputDeviceList, puiNumDevices, cbSize)
# pRawInputDeviceList : RAWINPUTDEVICELIST* optional, out -> "void*"
# puiNumDevices : DWORD* in/out -> "void*"
# cbSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。