http://www.nirsoft.net/utils/special_folders_view.html 그냥 참고.


바탕 화면의 문자열

CString GetDesktopLabel ( int *sysIconIndex )

{

    TCHAR path [ MAX_PATH ] = "" ;

    LPMALLOC pMalloc ;

    SHGetMalloc ( &pMalloc ) ;

    SHFILEINFO sfi = { 0 , } ;

    // 'Desktop' or '바탕 화면' text

    LPITEMIDLIST pidl ;

    SHGetSpecialFolderLocation ( nullptr , CSIDL_DESKTOP , &pidl ) ;

    SHGetFileInfo ( (char*) pidl , 0 , &sfi , sizeof ( sfi ) , SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX | SHGFI_PIDL ) ;

    pMalloc->Free ( pidl ) ;

    pMalloc->Release ( ) ;

 

    if ( sysIconIndex != nullptr )

{

        *sysIconIndex = sfi.iIcon ;

    }


    return sfi.szDisplayName ;

}


바탕 화면 실제 경로

TCHAR desktop_path [ MAX_PATH ] = "" ;

SHGetSpecialFolderPath ( nullptr , desktop_path , CSIDL_DESKTOPDIRECTORY , 0 ) ;


내 문서 문자열

CString GetMyDocumentLabel ( int *sysIconIndex )

{

    LPMALLOC pMalloc ;

    SHGetMalloc ( &pMalloc ) ;

    SHFILEINFO sfi = { 0 , } ;

    // 'My Document' or '내 문서' text

    LPITEMIDLIST pidl ;

    SHGetSpecialFolderLocation ( nullptr , CSIDL_PERSONAL , &pidl ) ;

    SHGetFileInfo ( (char*) pidl , 0 , &sfi , sizeof ( sfi ) , SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX | SHGFI_PIDL ) ;

    pMalloc->Free ( pidl ) ;

    pMalloc->Release ( ) ;

 

    if ( sysIconIndex != nullptr )

{

        *sysIconIndex = sfi.iIcon ;

    }

    return sfi.szDisplayName ;

}


내 문서 실제 경로

TCHAR path [ MAX_PATH ] = "" ;

SHGetSpecialFolderPath ( nullptr , path , CSIDL_PERSONAL , 0 ) ;


내 컴퓨터의 문자열

CString GetMyComputerLabel ( int *sysIconIndex )
{
    LPMALLOC pMalloc ;
    SHGetMalloc ( &pMalloc ) ;
    SHFILEINFO sfi = { 0 , } ;
    // 'My Computer' or '내 컴퓨터' text
    LPITEMIDLIST pidl ;
    SHGetSpecialFolderLocation ( nullptr , CSIDL_DRIVES , &pidl ) ;
    SHGetFileInfo ( (char*) pidl , 0 , &sfi , sizeof ( sfi ) , SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX | SHGFI_PIDL ) ;
    pMalloc->Free ( pidl ) ;
    pMalloc->Release ( ) ;
 
    if ( sysIconIndex != nullptr )
{
        *sysIconIndex = sfi.iIcon ;
    }
    return sfi.szDisplayName ;
}