积极答复者
包含了#include <shlobj.h>,为什么还找不到SHBindToParent?

问题
答案
-
SHBindToParent
仅在Windows Embedded CE下可以使用,你可以在PB中找到它.
MSDN:
http://msdn.microsoft.com/en-us/library/aa932728.aspx
全部回复
-
我的代码如下:
#include <Shlobj.h>
#include <shlwapi.h>
#pragma comment ( lib, "Ceshell.lib" )
bool file()
{
IMalloc * pShellMalloc = NULL; // A pointer to the shell's IMalloc interface
IShellFolder *psfParent; // A pointer to the parent folder object's IShellFolder interface.
LPITEMIDLIST pidlItem = NULL; // The item's PIDL.
LPITEMIDLIST pidlRelative = NULL; // The item's PIDL relative to the parent folder.
STRRET str; // The structure for strings returned from IShellFolder.
WCHAR szDisplayName[MAX_STRING]= L""; // The display name's string for Favorites
WCHAR szPath[MAX_STRING] = L""; // The path for Favorites.
HRESULT hres = SHGetMalloc(&pShellMalloc);
if (FAILED(hres))
{
return false;
}
hres = SHGetSpecialFolderLocation(NULL,
CSIDL_FAVORITES,
&pidlItem);
if (SUCCEEDED(hres))
{
hres = SHBindToParent(pidlItem,
IID_IShellFolder,
(void**)&psfParent,
(LPCITEMIDLIST*)&pidlRelative);
if (SUCCEEDED(hres))
{
// Retrieve the display name
memset(&str, 0, sizeof(str));
hres = psfParent->GetDisplayNameOf(pidlRelative, SHGDN_NORMAL, &str);
if (SUCCEEDED(hres))
{
StrRetToBuf(&str, pidlItem, szDisplayName, sizeof(szDisplayName));
}
// Retrieve the path
memset(&str, 0, sizeof(str));
hres = psfParent->GetDisplayNameOf(pidlRelative, SHGDN_NORMAL | SHGDN_FORPARSING, &str);
if (SUCCEEDED(hres))
{
StrRetToBuf(&str, pidlItem, szPath, sizeof(szPath));
}
psfParent->Release();
}
}
// Clean up allocated memory
if (pidlItem)
{
pShellMalloc->Free(pidlItem);
}
if (pidlRelative)
{
pShellMalloc->Free(pidlRelative);
}
pShellMalloc->Release();
}
以上主体是MSDN里的例子
错误为:
Error 2 error C3861: 'SHBindToParent': identifier not found -
SHBindToParent
仅在Windows Embedded CE下可以使用,你可以在PB中找到它.
MSDN:
http://msdn.microsoft.com/en-us/library/aa932728.aspx