/// <summary> /// Retrieves information about the raw input device. /// </summary> /// <param name="hDevice">A handle to the raw input device. This comes from the <b>lParam</b> of the /// <see cref="WM.INPUT">WM_INPUT</see> message, from the <see cref="RAWINPUTHEADER.hDevice">hDevice</see> /// member of <see cref="RAWINPUTHEADER"/>, or from <see cref="GetRawInputDeviceList"/>. It can also be /// <b>null</b> (IntPtr.Zero) if an application inserts input data, for example, by using <b>SendInput</b>.</param> /// <returns>The information about the raw input device.</returns> public static RID_DEVICE_INFO GetRawInputDeviceInfo(HANDLE hDevice) { uint size = (uint)Marshal.SizeOf(typeof(RID_DEVICE_INFO)); RID_DEVICE_INFO ret = new RID_DEVICE_INFO(); ret.cbSize = size; uint err = GetRawInputDeviceInfo(hDevice, RIDI.DEVICEINFO, ref ret, ref size); if (err == uint.MaxValue) { throw new Exception(string.Format("Error determining device information. (Error code: 0x{0:X8})", WinKernel.GetLastError())); } return(ret); }
extern static uint GetRawInputDeviceInfo(HANDLE hDevice, RIDI uiCommand, ref RID_DEVICE_INFO pData, ref uint pcbSize);