I have a DEVINST, I need the Device Path

后端 未结 2 1354
隐瞒了意图╮
隐瞒了意图╮ 2021-01-16 01:50

I\'m trying to open a WinUSB device that is part of a composite device. I have located the correct child device using cfgmgr32, and have its DEVINST number. In order to open

2条回答
  •  终归单人心
    2021-01-16 02:28

    I recommend looking at the get_filename_from_devinst_and_guid function which is part of libusbp.

    The basic outline is:

    1. Make sure you know the device interface GUID you are looking for. That is the thing in brackets at the end of the filename you provided. This usually comes from the INF file that sets up WinUSB, though it can also come from MS OS descriptors on the device. You can find it in the registry. You have to pack it into a Win32 API GUID struct.
    2. Call SetupDiGetClassDevs(guid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); to get a list of all the present (connected) devices supporting that device interface GUID.
    3. Use SetupDiEnumDeviceInfo to iterate through the list until you find the item that matches the DEVINST you already found.
    4. Use SetupDiEnumDeviceInterfaces to get the list of interfaces for that item. There should only be one entry because you already specified the device interface GUID you are interested in.
    5. Use SetupDiGetDeviceInterfaceDetail to get SP_DEVICE_INTERFACE_DETAIL_DATA_A data structure.
    6. The filename you are looking for is in the DevicePath member of that structure.

提交回复
热议问题