How to construct path for mtp devices (usable in folder browse dialog)?

烂漫一生 提交于 2021-01-04 06:41:50

问题


I implemented file transfer from windows pc to an android device, which is connected with MTP to the computer. The copy implementation is ready (I used this example: http://code.msdn.microsoft.com/windowsdesktop/Portable-Devices-COM-API-fd4a5f7d).

Now I would like to improve UI, I would like to offer a folder selection dialog, where the user can select a MTP device folder, where I will save the file (CLSID_FileOpenDialog with FOS_PICKFOLDERS works nice). Note that simple file save dialog doesn't work, because you will get error from dialog: "You can’t save here".

The result of folder browsing will be similar to this:
::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\?\usb#vid_04e8&pid_6860&mi_00#6&2296b879&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SID-{10001,SECZ9519043CHOHB,12635222016}{01B8016B-0164-00F2-E100-55012C014001}

usb#vid_04e8&pid_6860&mi_00#6&2296b879&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}
I know this is the device, IPortableDeviceManager use this as device id.

SID-{10001,SECZ9519043CHOHB,12635222016}\{01B8016B-0164-00F2-E100-55012C014001}
This is the path on device. These GUIDs are the WPD_OBJECT_PERSISTENT_UNIQUE_ID property of the device objects.

With this information I can select the device and find the folder in the device, so I can do the copy.

My problem is that I also would like to select a default directory in my folderbrowsedialog on the device, and I can't create the upper mentioned path. Note if I give that as a default path, it starts the browsing in the correct folder.

The problematic part is the starting GUID, which I can't get:
::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

I also looked into registry. I found this GUID in only one entry:
HKEY_USERS\S-1-5-21-2044730494-4069800027-1247311059-1000\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID{20D04FE0-3AEA-1069-A2D8-08002B30309D}\DefaultIcon
which value is this:
C:\Windows\System32\imageres.dll,-109
(CLSID subfolder contains more GUID, so I can't find, which is the correct one)

Do you have idea how to get this GUID to be able to construct the whole default path?


回答1:


That guid represents the Computer folder, the shell namespace extension for MTP devices is a Computer folder delegate. You can use this guid as a constant to construct the parsing name for your folder browser.

Regards, lisa



来源:https://stackoverflow.com/questions/13452798/how-to-construct-path-for-mtp-devices-usable-in-folder-browse-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!