SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_LOCATION_INFORMATION,&dwPropertyRegDataType, (BYTE*)szDesc,sizeof(szDesc),&dwSize) S=szDesc n=64 while (s.Length()n) s=s.SubString(1,n) txt+=s+" " here you can do custom stuff for specific VID,PID just change the ? in above line to your specific VID,PID,REV SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_HARDWAREID,&dwPropertyRegDataType, (BYTE*)szDesc,sizeof(szDesc),&dwSize) S=szDesc n=48 while (s.Length()n) s=s.SubString(1,n) txt+=s+" " // this just set constant string size to allign the columns to n chars SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_DEVICEDESC,&dwPropertyRegDataType, (BYTE*)szDesc,sizeof(szDesc),&dwSize) If (!SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData)) break If (hDevInfo = INVALID_HANDLE_VALUE) return false ĭeviceInfoData.cbSize = sizeof(DeviceInfoData) HDevInfo = SetupDiGetClassDevs(NULL, TEXT("USB"), NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES) I do not code in C# nor WMI but you should be able to obtain this kind of info with setupapi.h which is part of winapi (I think) I do it like this in C++/VCL: #include I would try to extract location information from the USB device (the same as in device manager).
0 Comments
Leave a Reply. |