I\'m trying to determine what type my WPD device is in Delphi.
In my application I need to know if the device is a Phone or Camera or what ever it is.
According
Ok, so eventually I figured out how to read the device type of a device.
What needed to be done was to read the device properties.
Some very interesting information could be read, such as the battery level of the device, if available.
EDIT: I used the source found here as a reference to WPD programming.
Code tested with external harddrives, SD memory card reader, USB sticks, Apple iPhone, and Samsung Galaxy phone.
Code is available HERE!!!
Just copy and paste the code in to a new VCL project, add a listbox called DeviceList, a memo called LogMemo, a panel called Panel1, and a button inside Panel1 called Button1. Then doubleclick on the Listbox, and doubleclick on the button, and finally doubleclick on the main form, and everything should run flawlsessly.
Programmed in Delphi XE7.
Your HRESULT
is $80070002
. That's a COM error code that wraps the Win32 error code, ERROR_FILE_NOT_FOUND. And that means that either the device ID or property name are incorrect. Assuming that you have indeed got the correct device ID, the obvious conclusion is that you are attempting to read the value of a property that does not exist.