Can anyone verify if I am doing this right?
I am able to read the product and vendor ID's from an HID
device, so the CreateFile and the Get_Attributes
functions are working well. I am having a hard time
using WriteFile to send bytes to the device. I am
sending just 2 bytes to and x10 usb hid device. The
WriteFile call returns false.
Here is the CreateFile call:
handle = CreateFile(DeviceName,GENERIC_READ |
GENERIC_WRITE,FILE_SHARE_READ |
FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0);
Here is the WriteFile definition and call:
[DllImport("kernel32.dll", SetLastError=true)]
private static extern unsafe bool WriteFile(int
hFile,void* lpBuffer,int nBytesToWrite,int*
nBytesWritten,int overlapped);
public unsafe bool WriteBytes(int handle, byte[]
OutputReportBytes)
{
int BytesWritten = 0;
fixed (byte* p = OutputReportBytes)
{
return WriteFile(handle, p,
OutputReportBytes.Length, &BytesWritten, 0);
}
}
Any help here would be greatly appreciated.
Thanks in advance.