如何为 mtp 设备构建路径(可在文件夹浏览对话框中使用)? [英] How to construct path for mtp devices (usable in folder browse dialog)?
问题描述
我实现了从 windows pc 到 android 设备的文件传输,该设备通过 MTP 连接到计算机.复制实现已准备就绪(我使用了此示例:http://code.msdn.microsoft.com/windowsdesktop/Portable-Devices-COM-API-fd4a5f7d).
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).
现在我想改进 UI,我想提供一个文件夹选择对话框,用户可以在其中选择一个 MTP 设备文件夹,我将在其中保存文件(带有 FOS_PICKFOLDERS 的 CLSID_FileOpenDialog 效果很好).请注意,简单的文件保存对话框不起作用,因为您会从对话框中收到错误消息:您无法在此处保存".
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".
文件夹浏览的结果会是这样的:
::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\?usb#vid_04e8&pid_6860&mi_00#6&2296b879&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}SSECZ9519043CHOHB,12635222016}{01B8016B-0164-00F2-E100-55012C014001}
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}
我知道这是设备,IPortableDeviceManager 使用它作为设备 ID.
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}
这是设备上的路径.这些 GUID 是设备对象的 WPD_OBJECT_PERSISTENT_UNIQUE_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.
有问题的部分是我无法获得的起始 GUID:
::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
The problematic part is the starting GUID, which I can't get:
::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
我还查看了注册表.我只在一个条目中找到了这个 GUID:
HKEY_USERSS-1-5-21-2044730494-4069800027-1247311059-1000SoftwareMicrosoftWindowsCurrentVersionExplorerCLSID{20D04FE0-3AEA-1069-A2D8-08002B30309D}DefaultIcon
这是哪个值:
C:WindowsSystem32imageres.dll,-109
(CLSID子文件夹包含更多的GUID,所以我找不到,哪个是正确的)
I also looked into registry. I found this GUID in only one entry:
HKEY_USERSS-1-5-21-2044730494-4069800027-1247311059-1000SoftwareMicrosoftWindowsCurrentVersionExplorerCLSID{20D04FE0-3AEA-1069-A2D8-08002B30309D}DefaultIcon
which value is this:
C:WindowsSystem32imageres.dll,-109
(CLSID subfolder contains more GUID, so I can't find, which is the correct one)
你知道如何让这个 GUID 能够构建整个默认路径吗?
Do you have idea how to get this GUID to be able to construct the whole default path?
推荐答案
该 guid 代表计算机文件夹,MTP 设备的外壳命名空间扩展是计算机文件夹委托.您可以将此 guid 用作常量来构造文件夹浏览器的解析名称.
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.
问候,丽莎
这篇关于如何为 mtp 设备构建路径(可在文件夹浏览对话框中使用)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!