如何获得给定PIDL的IWMDMStorageControl接口 [英] How to get IWMDMStorageControl interface for given PIDL
问题描述
我使用SHBrowseForFolder()在MTP设备上选择一个文件夹。然后我想从/到那里复制文件。 IWMDMStorageControl接口(从Windows Media Format 11 SDK)似乎是合适的,但是如何获得它的对象与PIDL,从SHBrowseForFolder()?返回。
I use SHBrowseForFolder() to select a folder on MTP device. Then I want to copy file from/to there. IWMDMStorageControl interface (from Windows Media Format 11 SDK) seems suitable, but how to get it for the object with PIDL, returned from SHBrowseForFolder()?
关于获取IWMDMStorageControl接口:如何为给定PIDL获取IPortableDeviceContent接口)
(I asked similar question about obtaining IWMDMStorageControl interface: How to get IPortableDeviceContent interface for given PIDL)
推荐答案
我们可以通过这种方式从SHBrowseForFolder()获取与PILD关联的显示名称:
We can get the displayed name, associated with the PILD from SHBrowseForFolder() in this way:
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文件结构由相同的路径。这不是优雅的解决方案,但它是我发现的唯一的。
Then we can parse the path and traverse through MTP file structure by the same path. It is not elegant solution, but it is the only one which I found.
这篇关于如何获得给定PIDL的IWMDMStorageControl接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!