Last updated:
31. October 2001
(Start sub-menu)
(End sub-menu)
/* * $Header: /Book/getLongPathName.cpp 11 11.07.01 14:48 Oslph312 $ */ #include "precomp.h" #include "AutoComReference.h" #include "AutoShellObject.h" #include "utils.h" #include "os.h" #include <shlobj.h> // LATER: Create a Filename class; handle named streams properly. String getLongPathName( const String& strShort ) { String strLong; AutoComReference< IShellFolder > pShellFolder; HRESULT hres = SHGetDesktopFolder( &pShellFolder ); if ( SUCCEEDED( hres ) ) { #ifdef UNICODE #define wszShort const_cast< LPWSTR >( strShort.c_str() ) #else PATHNAMEW wszShort = { 0 }; multiByteToWideChar( strShort.c_str(), wszShort ); #endif ULONG ulEaten = 0; ULONG ulAttributes = 0; AutoShellObject< ITEMIDLIST > pidl; hres = pShellFolder->ParseDisplayName( HWND_DESKTOP, 0, wszShort, &ulEaten, &pidl, &ulAttributes ); if ( SUCCEEDED( hres ) ) { strLong = getPathFromIDList( pidl ); } } // In case of failure, keep the short name: // TODO: Check error code -2147467259 (0x80004005) (Unspecified error) if ( !SUCCEEDED( hres ) || strLong.empty() ) { strLong = strShort; } return strLong; } // end of file
(Start bottom menu)
Top •
Home
• Articles
• Book
• Resources
Windows Developer Magazine
• R&D Books
• CMP Books
Amazon.com
• Amazon.co.uk
• Contact Petter Hesselberg
(End bottom menu)
getLongPathName.cpp