Opening device with CreateFile fails with error code 5 ERROR_ACCESS_DENIED
Hi,
I must confess I don't do this in c++, but since there is no forum for vb.net, I'll try to make it simple (If you disagree on this thread being here please feel free to delete it).
Re: Opening device with CreateFile fails with error code 5 ERROR_ACCESS_DENIED
A DT-Box which purpose is to convert SY-4 to USB (eg. I have a device that returns some values and this box is seen by Windows as Human Interface Device).
Box has one button which sends data taken from device to keyboard.
Success = False (and NumberOfBytesWritten = 0) so I try:
Marshal.GetLastWin32Error()
and get error 1 = ERROR_INVALID_FUNCTION (Incorrect function.)
Definition of WriteFile:
<DllImport("kernel32.dll", setlasterror:=True)> Private Shared Function WriteFile _
(ByVal hFile As Integer, _
ByRef lpBuffer As Byte, _
ByVal nNumberOfBytesToWrite As Integer, _
ByRef lpNumberOfBytesWritten As Integer, _
ByVal lpOverlapped As Integer) _
As Boolean
End Function
Yeah it is, i was trying that function and then tried WriteFile and decided I need WriteFile and forgot to change the name of buffer, but that doesn't make any difference.
From the beginning, I try to simulate button press on HID. How to do that? WriteFile and DeviceIoControl are good way? If so I can't use them because of error access denied. Any other function or easier way to do that? Can it be done with DirectX? Thanks for help anyway.
So, i tried using guid (since when I discover my device and get it's "name" it contains guid):
deviceGuid = "{884b96c3-56ef-11d1-bc8c-00a0c91405dd}"
Dim devguid As System.Guid = New System.Guid(deviceGuid)
Dim gamepadDevice As Device = New Device(devguid)
Re: Opening device with CreateFile fails with error code 5 ERROR_ACCESS_DENIED
>> Any ideas on Simulating a key press on non-standard (eg. not joystick) HID?
So you want the OS (and some application) to think a HID report is coming from the actual device? I don't think you can do that by simply writing to the device [driver] (unless the device [driver] explicitly echos back what's written to it).
You could create your own HID driver that sends up your own HID reports, but if the software that is reading those reports is looking for a specific device (product/vendor ID) then that may not work either. http://www.microsoft.com/whdc/devtools/DSF.mspx
Re: Opening device with CreateFile fails with error code 5 ERROR_ACCESS_DENIED
Originally Posted by Codeplug
>> Any ideas on Simulating a key press on non-standard (eg. not joystick) HID?
So you want the OS (and some application) to think a HID report is coming from the actual device? I don't think you can do that by simply writing to the device [driver] (unless the device [driver] explicitly echos back what's written to it).
You could create your own HID driver that sends up your own HID reports, but if the software that is reading those reports is looking for a specific device (product/vendor ID) then that may not work either. http://www.microsoft.com/whdc/devtools/DSF.mspx
gg
Yes it has specific vid and pid (and i know them). But, device puts data on "keyboard" eg. it does keypresses of data, so I detect them with GetAsyncKeyState (and that works and it isn't problem), so only thing i need now is to press that button
Bookmarks