Kiran's Blog

Ramblings from a dehydrated mind…

  • Archives

    • 14,897

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: