Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Handle is Valid but is a very small value.

$
0
0

I am successfully getting a handle to a USB Keyboard device, but the actual handle value I get doesn't look right to me. The value is typically like this: 0x0000009a. Also, subsequent use of this handle fails. Any ideas why I get this strange handle value?

(For information, I am trying to control the NUMLOCK lamp on multiple keyboards, and so need a different handle to each keyboard).

The code, in which 'longDeviceName' is "\\?\HID#VID_413C&PID_2107#7&2A1ABB0E&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD}", is as follows;

int lastErr = 0;
HANDLE hFile = CreateFile( ( LPCTSTR )longDeviceName,
                           GENERIC_WRITE,
                           FILE_SHARE_READ | FILE_SHARE_WRITE,
                           NULL,
                           OPEN_EXISTING,
                           FILE_FLAG_OVERLAPPED,
                           NULL );
if ( hFile == INVALID_HANDLE_VALUE )
{
    lastErr = GetLastError();
}


Regards, Pennant Mike.



Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>