Kiran's Blog

Ramblings from a dehydrated mind…

  • Archives

  • Blog Stats

    • 9,866

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();
           }
       }

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>