Hi Tim, Doron,
Sorry for the typo, I mean GetFeatureReport.
After desperating a little bit I have found that the problem was due to file handle permissions. However this, can become quite critic. Let me explain.
hid_api, originally defines the open_device the way below. Depending on if it is called during a simple enumerate or a explict open, a boolean flag enumerate is specified, which will condition the desired access and share mode. On my first experience with this lib on Windows 8 (didn’t test it on Windows 7 yet), I had to modify desired_access to (GENERIC_WRITE | GENERIC_READ) and share_mode to (FILE_SHARE_READ|FILE_SHARE_WRITE), otherwise I couldn’t make any request to the device, only list them.
Since my upgrade do Windows 8.1 yesterday, I had to change the desired_access and share mode to (GENERIC_WRITE | GENERIC_READ) and FILE_SHARE_READ respectively.
As you might agree, this effectively concerns me. First of all, why isn’t this coehrent across Windows versions? How can I guarantee that my control panel will work across several Windows versions?
I hope your expertise can help me understand the differences and what should I do in order to keep my “sanity intact”! ![:slight_smile: :slight_smile:](/images/emoji/twitter/slight_smile.png?v=12)
I’m using hid_api because it saves me the hassle of writing custom code for Windows, Linux and Mac OSX. Beside this question of the open device desired access and share mode, I hadn’t any other problem with the lib so far. Below is the code for open_device and the link for hid_api github project.
static HANDLE open_device(const char *path, BOOL enumerate)
{
HANDLE handle;
DWORD desired_access = (enumerate)? 0: (GENERIC_WRITE | GENERIC_READ);
DWORD share_mode = (enumerate)?
FILE_SHARE_READ|FILE_SHARE_WRITE:
FILE_SHARE_READ;
handle = CreateFileA(path,
desired_access,
share_mode,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,/*FILE_ATTRIBUTE_NORMAL,*/
0);
return handle;
}
https://github.com/signal11/hidapi/blob/master/windows/hid.c
With my best regards,
Nuno Santos