Public Declare Auto Function GetRawInputDeviceList Lib "user32.dll" ( _
<MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=1, ArraySubType:=UnmanagedType.Struct), [In](), Out()> ByVal pRawInputDeviceList As RAWINPUTDEVICELIST(), _
<[In](), Out()> ByRef puiNumDevices As Int32, _
<[In]()> ByVal cbSize As Int32) As Int32
Due to marshalling limitations this function must be called twice to obtain list of devices.
Dim List As RAWINPUTDEVICELIST()
Dim Number% = 0
Dim Ret = GetRawInputDeviceList(Nothing, Number, RAWINPUTDEVICELIST.Size)
If Ret = -1 Then
'Error
Exit Sub
End If
ReDim List(Number - 1)
Ret = GetRawInputDeviceList(List, Number, RAWINPUTDEVICELIST.Size)
If Ret = -1 Then
'Error
Exit Sub
End If
'Do something with items in the List array