Determine WPD device type in Delphi

前端 未结 2 1494
粉色の甜心
粉色の甜心 2021-01-27 08:28

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

相关标签:
2条回答
  • 2021-01-27 08:34

    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.

    0 讨论(0)
  • 2021-01-27 08:41

    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.

    0 讨论(0)
提交回复
热议问题