Home > Back-end >  How to get the USB device Location Info information? In UsbTreeView can see
How to get the USB device Location Info information? In UsbTreeView can see

Time:01-17

In UsbTreeView software can see the Location Info information, red line below the logo, but I use SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces, SetupDiGetDeviceInstanceId, SetupDiGetDeviceRegistryPropertyA, functions are used, such as how to just can't find the Location Info information? In addition with yellow marked place, how to have two Device ID? But also not the same, I can only get the second Device ID, how can I get the first Device ID?

CodePudding user response:

https://docs.microsoft.com/en-us/previous-versions/ff537421 (v=vs. 85)
Look, look from the description should be IOCTL_INTERNAL_USB_GET_TOPOLOGY_ADDRESS

CodePudding user response:

Their top, hope expert guidance about

CodePudding user response:

The first device id should be a patriarchal attribute

SetupDiGetClassDevs obtain certain types of equipment such as online collection USB device set
SetupDiEnumDeviceInfo, in turn, the set of enumerated above, have the information corresponding to each device, such as instance ID
SetupDiGetDeviceInstanceId
CM_Get_Parent made a device instance instances of "father"

CodePudding user response:

refer to the second floor twohorses response:
top by oneself, hope ace to guide

, thank you for your help, SetupDiGetClassDevs, SetupDiEnumDeviceInfo SetupDiGetDeviceInstanceId this I use the three functions, not many, the information obtained from CM_Get_Parent this function is used, I'll try, but I want the usb port is the port number, in UsbTreeView a directory tree on the left there is a corresponding port number, I haven't get the port, so the above screenshot directory tree without cut, in the right Location in the paternity of the Info in the corresponding port # 0002 should be the port number, so how to get this information, as the chart, if we can directly obtain the Port2 that is the best in the directory tree on the left,

CodePudding user response:

This information is a little less

CodePudding user response:

SetupDiGetDeviceProperty DEVPKEY_Device_Parent attribute is a USB HUB, DEVPKEY_Device_LocationInfo attribute is a USB Port.

CodePudding user response:

refer to 6th floor BrillianceRen response:
SetupDiGetDeviceProperty DEVPKEY_Device_Parent attribute is a USB HUB, DEVPKEY_Device_LocationInfo attribute is a USB Port.

Thank you, I use this function, didn't find the port information, I'll try again, see if missed before

CodePudding user response:

refer to 6th floor BrillianceRen response:
SetupDiGetDeviceProperty DEVPKEY_Device_Parent attribute is a USB HUB, DEVPKEY_Device_LocationInfo attribute is a USB Port.


Consult SetupDiGetDeviceProperty this function to get that DEVPKEY_Device_LocationInfo properties, DEVPROPKEY how the parameter Settings? I look at a few examples on the web, set this parameter. Fmtid and. Pid are fixed, but also not the same, I don't know how to get this? My guid equipment is through the Result=HidD_GetHidGuid (HidGuid) this,

CodePudding user response:

refer to the eighth floor twohorses response:
Quote: refer to the sixth floor BrillianceRen response:

SetupDiGetDeviceProperty DEVPKEY_Device_Parent attribute is a USB HUB, DEVPKEY_Device_LocationInfo attribute is a USB Port.


Consult SetupDiGetDeviceProperty this function to get that DEVPKEY_Device_LocationInfo properties, DEVPROPKEY how the parameter Settings? I look at a few examples on the web, set this parameter. Fmtid and. Pid are fixed, but also not the same, I don't know how to get this? My guid equipment is through the Result=HidD_GetHidGuid (HidGuid) this,


 
#include
#include
#include
#include
#include

# pragma comment (lib, "setupapi. Lib")

#include
Using namespace STD.

Int main ()
{
HDEVINFO DeviceInfoSet=SetupDiGetClassDevsW (NULL, L "USB", NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
If (DeviceInfoSet==INVALID_HANDLE_VALUE)
return 0;
For (int I=0; ; I++) {
SP_DEVINFO_DATA DeviceInfoData;
DeviceInfoData. CbSize=sizeof (DeviceInfoData);
if (! SetupDiEnumDeviceInfo (DeviceInfoSet, I, & amp; DeviceInfoData))
break;
DWORD RequiredSize=0;
DEVPROPTYPE PropertyType=0;
WCHAR PropertyBuffer [4096]={0};
If (SetupDiGetDevicePropertyW (DeviceInfoSet, & amp; DeviceInfoData, & amp; DEVPKEY_Device_BusReportedDeviceDesc, & amp; PropertyType, reinterpret_cast & lt; PBYTE> (PropertyBuffer), sizeof (PropertyBuffer), & amp; RequiredSize, 0))
If (SetupDiGetDevicePropertyW (DeviceInfoSet, & amp; DeviceInfoData, & amp; DEVPKEY_Device_LocationInfo, & amp; PropertyType, reinterpret_cast & lt; PBYTE> (PropertyBuffer), sizeof (PropertyBuffer), & amp; RequiredSize, 0))
Wcout & lt; }
return 0;
}

CodePudding user response:

references 9 f BrillianceRen response:
Quote: refer to the eighth floor twohorses response:

Quote: refer to the sixth floor BrillianceRen response:

SetupDiGetDeviceProperty DEVPKEY_Device_Parent attribute is a USB HUB, DEVPKEY_Device_LocationInfo attribute is a USB Port.


Consult SetupDiGetDeviceProperty this function to get that DEVPKEY_Device_LocationInfo properties, DEVPROPKEY how the parameter Settings? I look at a few examples on the web, set this parameter. Fmtid and. Pid are fixed, but also not the same, I don't know how to get this? My guid equipment is through the Result=HidD_GetHidGuid (HidGuid) this,


 
#include
#include
  • Related