c++:How to associate the USB device and WPD device?

2 freeman 0 Reputation points
2023-11-22T06:41:27.04+00:00

Hi,

I want to write a c++ program to read files on a specified mobile phone. This program receives three parameters: the USB vendor ID, the USB product ID and the USB serial number. These three parameters should identify the mobile phone.

What puzzles me is: how can I determine which WPD device corresponds to the target based on these parameters?

I think I can identirfy the target by serial number. And I try to get the serial number through WPD:


pIPortableDeviceManager->GetDevices(devIDs, &devCount);

 this->pIPortableDevice->Open(devIDs[idx], this->pClientInfo)

this->pIPortableDevice->Content(&pContent);

pContent->Properties(&pProperties);

pProperties->GetValues(WPD_DEVICE_OBJECT_ID, NULL, &pValues);

pValues->GetStringValue(WPD_DEVICE_SERIAL_NUMBER, &serialNumber);

However, the serial number obtained from the WPD is different from the USB serial number:


WPD serial number: 032xxx1FDxxxD2Fxxx8B0xxxA0Axxx81

USB serial number: R5CxxxV6xxx

It looks like I can't determine which phone is the target by serial number.

I find that the device ID got from the IPortableDeviceManager::GetDevices() has the following format:


\\?\usb#vid_04e8&pid_6860&ms_comp_mtp&samsung_android#7&3axxx8f7&1&0000#{6acxxx78-axxx-4xxx-ba85-f98xxx1d4xxx}

I try to understand the meaning of this string based on this documentation: https://learn.microsoft.com/en-us/windows-hardware/drivers/install/standard-usb-identifiers.

Saddly, I still don't understand the meaning of some fields:


#7&3axxx8f7&1&0000#{6acxxx78-axxx-4xxx-ba85-f98xxx1d4xxx}

Which id can be used to associate the USB device and WPD device?

Thanks.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,181 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,633 questions
Windows Hardware Performance
Windows Hardware Performance
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Hardware Performance: Delivering / providing hardware or hardware systems or adjusting / adapting hardware or hardware systems.
1,577 questions
0 comments No comments
{count} votes