path of my documents folder
-
dear all, how can i retrieve the path of My Documents folder for specific users (say guest) ? is there any function which returns the path. my documents folder has different location in windows 9x and Xp........any way out? rIsHaBh
-
dear all, how can i retrieve the path of My Documents folder for specific users (say guest) ? is there any function which returns the path. my documents folder has different location in windows 9x and Xp........any way out? rIsHaBh
// Allocate a pointer to an Item ID list LPITEMIDLIST pidl; // Get a pointer to an item ID list that // represents the path of a special folder HRESULT hr = SHGetSpecialFolderLocation(NULL, /*CSIDL_SEARCH_MSDN*/, &pidl); // Convert the item ID list's binary // representation into a file system path char szPath[_MAX_PATH]; SHGetPathFromIDList(pidl, szPath); // Allocate a pointer to an IMalloc interface LPMALLOC pMalloc; // Get the address of our task allocator's IMalloc interface hr = SHGetMalloc(&pMalloc); // Free the item ID list allocated by SHGetSpecialFolderLocation pMalloc->Free(pidl); // Free our task allocator pMalloc->Release(); // Work with the special folder's path (contained in szPath) strcat(szPath , "\\Folder");
-
// Allocate a pointer to an Item ID list LPITEMIDLIST pidl; // Get a pointer to an item ID list that // represents the path of a special folder HRESULT hr = SHGetSpecialFolderLocation(NULL, /*CSIDL_SEARCH_MSDN*/, &pidl); // Convert the item ID list's binary // representation into a file system path char szPath[_MAX_PATH]; SHGetPathFromIDList(pidl, szPath); // Allocate a pointer to an IMalloc interface LPMALLOC pMalloc; // Get the address of our task allocator's IMalloc interface hr = SHGetMalloc(&pMalloc); // Free the item ID list allocated by SHGetSpecialFolderLocation pMalloc->Free(pidl); // Free our task allocator pMalloc->Release(); // Work with the special folder's path (contained in szPath) strcat(szPath , "\\Folder");
Or even simpler:
if ( SHGetSpecialFolderPath( NULL, pszMyDocFolder, CSIDL_PERSONAL, FALSE ) ) return pszMyDocFolder;
or:if( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_PERSONAL, // same as CSIDL_MYDOCUMENTS. SHGetFolderPath() & CSIDL_MYDOCUMENTS needs latest SDK NULL, 0, pszMyDocFolder ) ) ) { return pszMyDocFolder; }
depending on which version of the SDK you have installed. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com -
Or even simpler:
if ( SHGetSpecialFolderPath( NULL, pszMyDocFolder, CSIDL_PERSONAL, FALSE ) ) return pszMyDocFolder;
or:if( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_PERSONAL, // same as CSIDL_MYDOCUMENTS. SHGetFolderPath() & CSIDL_MYDOCUMENTS needs latest SDK NULL, 0, pszMyDocFolder ) ) ) { return pszMyDocFolder; }
depending on which version of the SDK you have installed. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.comthnx a ton guyz! rIsHaBh