是这样吗?
BOOL GetDesktopPath(CString &strPath)
{
int nCSIDIndex=CSIDL_DESKTOPDIRECTORY;
char Path[MAX_PATH+1];
LPITEMIDLIST pidl;
LPMALLOC pShellMalloc;
if(SUCCEEDED(SHGetMalloc(&pShellMalloc)))
{
if(SUCCEEDED(SHGetSpecialFolderLocation(NULL,
nCSIDIndex,&pidl)))
{
if(SHGetPathFromIDList(pidl, Path))
{
strPath=Path;
return TRUE;
}
else//SHGetPathFromIDList(pidl, Path))
{
return FALSE;
}
pShellMalloc->Free(pidl);
}
else//SHGetSpecialFolderLocation
{
return FALSE;
}
pShellMalloc->Release();
}
else//SUCCEEDED(SHGetMalloc(&pShellMalloc)))
{
return FALSE;
}
}