getting special folders path…
Posted by kiraninbng on July 27, 2006
Three simple steps to get the paths for special folders,
1. Use SHGetSpecialFolderLocation with appropriate nFolder value(2nd param)
2. SHGetPathFromIDList – Fetch the path name from returned Item Identifier list
3. Release the Item Identifier list
Below is an example,
LPITEMIDLIST pIDList;
HRESULT hr = SHGetSpecialFolderLocation(NULL,CSIDL_PERSONAL,&pIDList);
if(SUCCEEDED(hr))
{
char szSpecialFolderPath[_MAX_PATH];
if(SHGetPathFromIDList(pIDList,szSpecialFolderPath))
{
LPMALLOC pMalloc;
hr = SHGetMalloc(&pMalloc);
if(SUCCEEDED(hr))
{
pMalloc->Free(pIDList);
pMalloc->Release();
}
}