locked
Windows 8 cannot read HID raw data

    Question

  • I aready had solutions to commnunicate with HID device.

    It has worked well until Windows 7.

    but on windows 8 It makes error ACCESS_DENIED

       hDeviceHandle=CreateFile \
        (detailData->DevicePath, \
        GENERIC_READ|GENERIC_WRITE, \
        FILE_SHARE_READ|FILE_SHARE_WRITE, \
        NULL, \
        OPEN_EXISTING, \
        0 , \
        NULL);

    if I elimindate GENERIC_READ, it passed the step. but i could not read the data.

    is it windows 8 bug?

    or is there any other way for windows8?

    Monday, September 24, 2012 10:31 AM

Answers

All replies

  • check out the link

    http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/29c363f4-9873-4890-9379-22e5b4f73f6f

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff538731(v=vs.85).aspx

    http://channel9.msdn.com/events/BUILD/BUILD2011/HW-747T

    Monday, September 24, 2012 1:40 PM
  • Thank You Chris!
    Monday, September 24, 2012 10:37 PM
    Moderator
  • According to links,  there is not a method or technique for reading data from hid device using "CreateFile" in  hid.dll on Win 8?

    is it right?

    It is very confusing to me.

    if so,why does it work on Win 7 ?

    the softwares that already made with legacy WIN32 API are not available for Win8?

    please find the solution that keep it for Metro and not have to revert to the legacy Win32 API.

    Tuesday, September 25, 2012 12:58 AM
  • The legacy APIs are available on the desktop.  However they are not available from Windows Store apps.  If you have a HID function driver for your own device it is likely possible to get it working...
    Tuesday, September 25, 2012 1:46 AM
    Moderator
  • Dear Eric,

    according to link http://msdn.microsoft.com/en-us/library/windows/hardware/ff538731(v=vs.85).aspx

    in Step CreateFile , it always return invalid handle with GENERIC_READ option.

    error code is ERROR_ACCESS_DENIED

    if I eliminate GENERIC_READ option, it passed the step , but it cannot read data from device.

    this problems are only happened in Windows 8. on windows 7,XP no problems.

    Tuesday, September 25, 2012 2:08 AM
  • what do you mean HID function driver ?

    do you mean that I should make specific driver for our device?

    Tuesday, September 25, 2012 10:26 AM
  • My source is

     GUID Guid;
     HidD_GetHidGuid(&Guid);
     HANDLE hDevInfo;
     HANDLE hDeviceHandle;

     HIDD_ATTRIBUTES      Attributes;
     SP_DEVICE_INTERFACE_DATA   devInfoData;
     PSP_DEVICE_INTERFACE_DETAIL_DATA detailData;
     hDevInfo=SetupDiGetClassDevs \
      (&Guid, \
      NULL, \
      NULL, \
      DIGCF_PRESENT|DIGCF_INTERFACEDEVICE);
     devInfoData.cbSize = sizeof(devInfoData);

     int memberIndex=0;
     while(1)
     {
      BOOL result = SetupDiEnumDeviceInterfaces(hDevInfo,0,&Guid,memberIndex,&devInfoData);

      if(result != 0 )
      {
       ULONG uLength;
       ULONG uRequired;
       result = SetupDiGetDeviceInterfaceDetail(hDevInfo,&devInfoData,NULL,0,&uLength,NULL);
       detailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(uLength);
       detailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);

       result = SetupDiGetDeviceInterfaceDetail(hDevInfo,&devInfoData,detailData,uLength,&uRequired,NULL);
       AfxMessageBox(detailData->DevicePath );

       hDeviceHandle = CreateFile(detailData->DevicePath,GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING ,0,NULL);
       if(hDeviceHandle == INVALID_HANDLE_VALUE)
       {
        ShowError();
       }
       else
       {
        memset(&Attributes,0x00,sizeof(Attributes));
        Attributes.Size = sizeof(Attributes);
        result = HidD_GetAttributes(hDeviceHandle,&Attributes);

        CString szS;
        szS.Format(L"vender = %d product = %d",Attributes.VendorID ,Attributes.ProductID );
        AfxMessageBox(szS);

     

       }
       free(detailData);
      }
      else
      {
       break;
      }
      memberIndex++;
     
     }

    Tuesday, September 25, 2012 10:35 AM
  •  

    Here is a link to the sample for the HID function driver:

    http://code.msdn.microsoft.com/windowshardware/HID-Client-Sample-2e2a6281

    With regards to the code sample it is not possible to make it work for a Windows Store app.  For a desktop app the Windows 7 code will work.

    Best Wishes - Eric

    Tuesday, September 25, 2012 5:46 PM
    Moderator