GetRegisteredRawInputDevices
関数登録済みのRaw Inputデバイス一覧を取得する。
シグネチャ
// USER32.dll
#include <windows.h>
DWORD GetRegisteredRawInputDevices(
RAWINPUTDEVICE* pRawInputDevices, // optional
DWORD* puiNumDevices,
DWORD cbSize
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pRawInputDevices | RAWINPUTDEVICE* | outoptional |
| puiNumDevices | DWORD* | inout |
| cbSize | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
DWORD GetRegisteredRawInputDevices(
RAWINPUTDEVICE* pRawInputDevices, // optional
DWORD* puiNumDevices,
DWORD cbSize
);[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern uint GetRegisteredRawInputDevices(
IntPtr pRawInputDevices, // RAWINPUTDEVICE* optional, out
ref uint puiNumDevices, // DWORD* in/out
uint cbSize // DWORD
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetRegisteredRawInputDevices(
pRawInputDevices As IntPtr, ' RAWINPUTDEVICE* optional, out
ByRef puiNumDevices As UInteger, ' DWORD* in/out
cbSize As UInteger ' DWORD
) As UInteger
End Function' pRawInputDevices : RAWINPUTDEVICE* optional, out
' puiNumDevices : DWORD* in/out
' cbSize : DWORD
Declare PtrSafe Function GetRegisteredRawInputDevices Lib "user32" ( _
ByVal pRawInputDevices 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
GetRegisteredRawInputDevices = ctypes.windll.user32.GetRegisteredRawInputDevices
GetRegisteredRawInputDevices.restype = wintypes.DWORD
GetRegisteredRawInputDevices.argtypes = [
ctypes.c_void_p, # pRawInputDevices : RAWINPUTDEVICE* 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')
GetRegisteredRawInputDevices = Fiddle::Function.new(
lib['GetRegisteredRawInputDevices'],
[
Fiddle::TYPE_VOIDP, # pRawInputDevices : RAWINPUTDEVICE* optional, out
Fiddle::TYPE_VOIDP, # puiNumDevices : DWORD* in/out
-Fiddle::TYPE_INT, # cbSize : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetRegisteredRawInputDevices(
pRawInputDevices: *mut RAWINPUTDEVICE, // RAWINPUTDEVICE* 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 GetRegisteredRawInputDevices(IntPtr pRawInputDevices, ref uint puiNumDevices, uint cbSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetRegisteredRawInputDevices' -Namespace Win32 -PassThru
# $api::GetRegisteredRawInputDevices(pRawInputDevices, puiNumDevices, cbSize)#uselib "USER32.dll"
#func global GetRegisteredRawInputDevices "GetRegisteredRawInputDevices" sptr, sptr, sptr
; GetRegisteredRawInputDevices varptr(pRawInputDevices), varptr(puiNumDevices), cbSize ; 戻り値は stat
; pRawInputDevices : RAWINPUTDEVICE* optional, out -> "sptr"
; puiNumDevices : DWORD* in/out -> "sptr"
; cbSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global GetRegisteredRawInputDevices "GetRegisteredRawInputDevices" var, var, int ; res = GetRegisteredRawInputDevices(pRawInputDevices, puiNumDevices, cbSize) ; pRawInputDevices : RAWINPUTDEVICE* optional, out -> "var" ; puiNumDevices : DWORD* in/out -> "var" ; cbSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetRegisteredRawInputDevices "GetRegisteredRawInputDevices" sptr, sptr, int ; res = GetRegisteredRawInputDevices(varptr(pRawInputDevices), varptr(puiNumDevices), cbSize) ; pRawInputDevices : RAWINPUTDEVICE* optional, out -> "sptr" ; puiNumDevices : DWORD* in/out -> "sptr" ; cbSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetRegisteredRawInputDevices(RAWINPUTDEVICE* pRawInputDevices, DWORD* puiNumDevices, DWORD cbSize) #uselib "USER32.dll" #cfunc global GetRegisteredRawInputDevices "GetRegisteredRawInputDevices" var, var, int ; res = GetRegisteredRawInputDevices(pRawInputDevices, puiNumDevices, cbSize) ; pRawInputDevices : RAWINPUTDEVICE* optional, out -> "var" ; puiNumDevices : DWORD* in/out -> "var" ; cbSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetRegisteredRawInputDevices(RAWINPUTDEVICE* pRawInputDevices, DWORD* puiNumDevices, DWORD cbSize) #uselib "USER32.dll" #cfunc global GetRegisteredRawInputDevices "GetRegisteredRawInputDevices" intptr, intptr, int ; res = GetRegisteredRawInputDevices(varptr(pRawInputDevices), varptr(puiNumDevices), cbSize) ; pRawInputDevices : RAWINPUTDEVICE* 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")
procGetRegisteredRawInputDevices = user32.NewProc("GetRegisteredRawInputDevices")
)
// pRawInputDevices (RAWINPUTDEVICE* optional, out), puiNumDevices (DWORD* in/out), cbSize (DWORD)
r1, _, err := procGetRegisteredRawInputDevices.Call(
uintptr(pRawInputDevices),
uintptr(puiNumDevices),
uintptr(cbSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetRegisteredRawInputDevices(
pRawInputDevices: Pointer; // RAWINPUTDEVICE* optional, out
puiNumDevices: Pointer; // DWORD* in/out
cbSize: DWORD // DWORD
): DWORD; stdcall;
external 'USER32.dll' name 'GetRegisteredRawInputDevices';result := DllCall("USER32\GetRegisteredRawInputDevices"
, "Ptr", pRawInputDevices ; RAWINPUTDEVICE* optional, out
, "Ptr", puiNumDevices ; DWORD* in/out
, "UInt", cbSize ; DWORD
, "UInt") ; return: DWORD●GetRegisteredRawInputDevices(pRawInputDevices, puiNumDevices, cbSize) = DLL("USER32.dll", "dword GetRegisteredRawInputDevices(void*, void*, dword)")
# 呼び出し: GetRegisteredRawInputDevices(pRawInputDevices, puiNumDevices, cbSize)
# pRawInputDevices : RAWINPUTDEVICE* optional, out -> "void*"
# puiNumDevices : DWORD* in/out -> "void*"
# cbSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。