Hi
In the code below, why do you need a separate a read and write handle? I would have thought the overlapped one could do both.
Thanks!
// Get handles to use in requesting Input and Output reports.
readHandle = FileIO.CreateFile(myDevicePathName, FileIO.GENERIC_READ, FileIO.FILE_SHARE_READ | FileIO.FILE_SHARE_WRITE, IntPtr.Zero, FileIO.OPEN_EXISTING, FileIO.FILE_FLAG_OVERLAPPED, 0);
functionName = "CreateFile, ReadHandle";
Debug.WriteLine(MyDebugging.ResultOfAPICall(functionName));
Debug.WriteLine( " Returned handle: " + readHandle.ToString() );
if ( readHandle.IsInvalid )
{
exclusiveAccess = true;
lstResults.Items.Add( "The device is a system " + hidUsage + "." );
lstResults.Items.Add( "Windows 2000 and Windows XP obtain exclusive access to Input and Output reports for this devices." );
lstResults.Items.Add( "Applications can access Feature reports only." );
ScrollToBottomOfListBox();
}
else
{
writeHandle = FileIO.CreateFile(myDevicePathName, FileIO.GENERIC_WRITE, FileIO.FILE_SHARE_READ | FileIO.FILE_SHARE_WRITE, IntPtr.Zero, FileIO.OPEN_EXISTING, 0, 0);
functionName = "CreateFile, WriteHandle";
Debug.WriteLine(MyDebugging.ResultOfAPICall(functionName));
Debug.WriteLine( " Returned handle: " + writeHandle.ToString() );
// Flush any waiting reports in the input buffer. (optional)
MyHid.FlushQueue( readHandle );