You have to call the function once passing NULL (zero) in the first argument to find out how many there are. Then call it again passing it an array of structures. If the first call returns 10, then the array needs to have 10 occurrences prior to the second call. You'll need two external definitions of the function, one where the first argument is ulong and the second where it is the structure.
The free function doesn't need to be replicated. The malloc would be replaced by code that would force the corrent number of occurrences into the array. Just set a value into the last occurrence.
I'm waking up this discussion because I have a requirement to distinguish whether input is coming from the keyboard or a usb bar code scanner. Windows doesn't provide this insight to the Key event but an App can get it from the RawInputDeviceApi
I wondering if you have some insight into this HID (human interface device) API
There are no replies made for this question yet. However, you are not allowed to reply to this question.
Please login to post a reply
You will need to be logged in to be able to post a reply. Login using the form on the right or register an account if you are new here. Register Here »
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.
I'm waking up this discussion because I have a requirement to distinguish whether input is coming from the keyboard or a usb bar code scanner. Windows doesn't provide this insight to the Key event but an App can get it from the RawInputDeviceApi
I wondering if you have some insight into this HID (human interface device) API
This article has a c# example https://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard
Based on this MS definition:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-rawinputdevice
I created this structure
global type rawinputdevice from structure
uint usUsagePage
uint usUsage
ulong dwFlags
ulong hwndTarget
end type
To get started : Based on your suggestion above I added these two external function definitions
//Calling this function causes a system error -- wrong type for param 1 ??
function UINT GetRawInputDeviceList_size( long usize , ref UINT puiNumDevices, ref UINT cbSize) library 'user32.dll'
//Calling this function returns -1 ??
function UINT GetRawInputDeviceList( ref RAWINPUTDEVICE pRawInputDevices [ ] , ref UINT puiNumDevices, ref UINT cbSize) library 'user32.dll'
Here's the PB code (button click)
RAWINPUTDEVICE str_RawInputDevices_null ,str_RawInputDevices [ ]
UINT lui_NumDevices, lui_cbSize
int rc
//setnull (str_RAWINPUTDEVICEs_null) // compiler won't allow this
//long lsize
//setnull(lsize)
//GetRawInputDeviceList( lsize , lui_NumDevices, lui_cbSize) //<<causes system error
rc = GetRawInputDeviceList( str_RawInputDevices , lui_NumDevices, lui_cbSize)
Suggestion?
Thanks
Yakov
yakov.werde@iongroup.com
Check your data types here:
https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types?redirectedfrom=MSDN
Handles (HWND for example) should be Longptr so that it will work in 64bit.