我们可以通过这种方式从 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文件结构。这不是优雅的解决方案,但它是我发现的唯一一个。