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; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)