Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the list of all the files(objects) in a folder exposed by an MTP device using Windows Portable Devices C++ API?

Tags:

c++

com

winapi

mtp

wpd

It is possible to enumerate all the files in an MTP device's file system and then get object id's for each file/folder in the system.

My questions are:

  1. Is there a method to find if an object is a file or a folder?
  2. Once the folder is found how to get the list of all files(Objects) in it ?

I have checked the Programmer's reference page in msdn website but did not find anything relevant. Am I missing something ?

Thanks!

like image 722
sp497 Avatar asked Nov 07 '25 20:11

sp497


1 Answers

  1. Using IPortableDeviceValues (which you get from the IPortableDeviceProperties::GetValues() method), query for WPD_OBJECT_CONTENT_TYPE. It will return WPD_CONTENT_TYPE_FOLDER if the object is a folder.

  2. Using the IPortableDeviceContent::EnumObjects() method, you can enumerate the content of any folder objects.

like image 169
Jonathan Potter Avatar answered Nov 09 '25 13:11

Jonathan Potter