我使用SHBrowseForFolder()在MTP设备上选择一个文件夹。然后我想从/到那里复制文件。 IWMDMStorageControl接口(来自Windows Media Format 11 SDK)似乎合适,但如何从具有PIDL的对象获取它,从SHBrowseForFolder()返回?
(我问了关于获取IWMDMStorageControl接口的类似问题:How to get IPortableDeviceContent interface for given PIDL)
答案 0 :(得分:0)
我们可以通过这种方式从SHBrowseForFolder()中获取与PILD相关联的显示名称:
TCHAR DisplayName[MAX_PATH]; // we will get it here
LPITEMIDLIST pidlSelected = SHBrowseForFolder( &bi );
if ( pidlSelected && ! SHGetPathFromIDList(pidlSelected, DisplayName) )
{ // it is media device
IShellFolder *psfParent;
LPCITEMIDLIST pidlRelative;
STRRET str;
HRESULT hres = SHBindToParent(pidlSelected, IID_IShellFolder, (void**)&psfParent, &pidlRelative);
if (SUCCEEDED(hres))
{
psfParent->GetDisplayNameOf( pidlRelative, SHGDN_FORADDRESSBAR, &str );
psfParent->Release();
StrRetToBuf( &str, pidlSelected, DisplayName, sizeof(DisplayName)/sizeof(DisplayName[0]) );
}
}
然后我们可以解析路径并通过相同的路径遍历MTP文件结构。这不是优雅的解决方案,但它是我找到的唯一一个。