none
WinUsb_Initialize returns FALSE, but GetLastError returns ERROR_SUCCESS. RRS feed

  • Question

  • Hi everyone.

    I am trying to develop WinUsb Application for HID device.

    At first, the usb device's "Device Handle" is got by CreateFile function.
    Next, I get VID and PID by HidD_GetAttributes function.
    Thus, it seemed to succeed in acquiring a device handle.

    But I cannot get the WinUSB INTERFACE HANDLE by WinUSB_Initialize function, WinUSB_Initialize returns FALSE, and GetLastError returns ERROR_SUCCESS.

    Why cannot I get error code by GetLastError ?
    And, why cannot the application get WinUSB INTERFACE HANDLE ?

    • Moved by DotNet Wang Monday, November 7, 2016 2:06 AM
    Friday, November 4, 2016 8:41 AM

Answers

  • let's be clear. NO HID devices using the HID drivers can use winusb. if you want to use the winusb API you must replace the driver with winusb.sys. and remember, not all HIDs are USB.

    what bigger problem are you trying to solve?


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, November 7, 2016 8:10 AM

All replies

  • Hi Aki.Naga,

    Based on your description, your case more related to  WinUsb Driver Development, I help

    moved your case to  Windows Hardware WDK and Driver Development forum for better support.    

    Best regards,

    Kristin                   


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Kristin Xie Monday, November 7, 2016 2:08 AM
    Monday, November 7, 2016 2:08 AM
  • Not all HID devices can be accessed via winusb. Some classes such as keyboard, mouse are reserved by the system. Other HID devices may be handled just with the in-box HID support (hid.dll, #include <hidsdi.h>, #include <hidpi.h> )



    Monday, November 7, 2016 2:27 AM
  • let's be clear. NO HID devices using the HID drivers can use winusb. if you want to use the winusb API you must replace the driver with winusb.sys. and remember, not all HIDs are USB.

    what bigger problem are you trying to solve?


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, November 7, 2016 8:10 AM
  • Hi Kristin.

    Thank you for your kindness.
    This is my first contribution, so I could not understand best selection.
    Monday, November 7, 2016 11:03 AM
  • Hi Pavel A,

    My device's class code is 0x03, subclass code and protocol are 0x00.

    Cannot this device be accessed via winusb?  

    I’d like to make a success of the WinUsb_initialize function  first.

    Monday, November 7, 2016 11:57 AM
  • Hi Doron Holan.

    Yes, I understand not all HIDs are USB.
    But,My device is USB device, and Vendor ID and Product ID are matched in check flow.

    I'm developing  PC application for PIC's bootloader(dsPIC33E_PIC24E Bootloader).
    A sample source is exhibited, but it isn't possible to use it just as it is because I can't use MFC.
    I'd like to develop it via Visual Studio C++ Express.

    Monday, November 7, 2016 12:13 PM
  •  but it isn't possible to use it just as it is because I can't use MFC.
    I'd like to develop it via Visual Studio C++ Express.

    But you don't have to use Express. For the same low price of $0.00 you can get Community edition which includes MFC. 

    Anyway, MFC mostly is GUI. What method that sample source uses to talk to the device? HID or not?

    -- pa


    • Edited by Pavel A Monday, November 7, 2016 5:26 PM
    Monday, November 7, 2016 5:19 PM
  • I think there is a misunderstanding here. WinUSB does not give you USB access to any USB device controlled by any USB client driver. WinUSB only gives you USB access if the winusb.sys driver is installed as the client driver. for instance, WinUSB is not meant to allow USB access to a HID while the HID driver is loaded. If you want to use winusb on the HID, you must remove the HID driver and install winusb.sys. But I really don't think you want to do that in this case, you should be using the HID APIs.

    What bigger problem are you trying to solve that makes you want to use WinUSB?


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, November 7, 2016 6:42 PM
  • Your information is very useful!

    I thought that the MFC is not included in VS Community edition.

    I'll try it.

    The sample source uses HID.

    Wednesday, November 9, 2016 11:24 AM
  • I thought WinUSB is able to use all of USB-HID drivers.

    Now, I'm understanding a little that WinUSB is need for the driver for it.

    And, I'll study HID APIs.


    Wednesday, November 9, 2016 11:42 AM