hi
i want to get device name of HID device using GetRawInputDeviceInfo method of User32.dll. And i am getting window handle from lparam of WndProc Message as mentioned in
GetRawInputDeviceInfo function (Windows)[
^] but it give pcbSize=0 always.
protected override void WndProc(ref Message m)
{
if (m.Msg == 0xFF)
{
string deviceName = GetDeviceName(m.LParam);
}
}
public string GetDeviceName(IntPtr DeviceHandle)
{
uint pcbSize = 0;
string deviceName="";
GetRawInputDeviceInfo(DeviceHandle, RIDI_DEVICENAME, IntPtr.Zero, ref pcbSize);
if (pcbSize > 0)
{
IntPtr pData = Marshal.AllocHGlobal((int)pcbSize);
GetRawInputDeviceInfo(DeviceHandle, RIDI_DEVICENAME, pData, ref pcbSize);
deviceName = Marshal.PtrToStringAnsi(pData);
Marshal.FreeHGlobal(pData);
}
return deviceName;
}
What i am doing wrong here ?
I want to get device name from WndProc message simply.