获取桌面收藏夹等目录

// Get the name of the "My Documents" folder and add it if(SUCCEEDED(SHGetSpecialFolderPath(NULL, szPath, CSIDL_PERSONAL, FALSE))) if(SUCCEEDED(SHGetSpecialFolderPath(NULL, szPath, CSIDL_FAVORITES, FALSE))) if(SUCCEEDED(SHGetSpecialFolderPath(NULL, szPath, CSIDL_DESKTOPDIRECTORY, FALSE))) if(SUCCEEDED(SHGetSpecialFolderPath(NULL, szPath, CSIDL_FONTS, FALSE))) if(SUCCEEDED(SHGetSpecialFolderPath(NULL, szPath, CSIDL_DRIVES, FALSE))) { LPSFOLDER tmpPath = afxEmptyString; int iTmpAddedItem = -1; tmpStr.LoadString(IDS_MYCOMPUTER); iMainAddedItem = AddString(tmpStr); // Set folder name/text if(iMainAddedItem != CB_ERRSPACE) { CString tmpStr, sLocalHardDrives; LPSFOLDER tmpFolder; // Finish with the "My Computer stuff" tmpMainFolder = new SFOLDER; tmpMainFolder->m_iImageIndex = 6; tmpMainFolder->m_iIndent = 1; tmpMainFolder->m_sFolderName = tmpStr; tmpMainFolder->m_sPathName = szPath; SetItemDataPtr(iMainAddedItem, tmpMainFolder); // Add the local hard drive stuff tmpStr.LoadString(IDS_LOCALHARDRIVES); iTmpAddedItem = AddString(tmpStr); // Set folder name/text if(iTmpAddedItem != CB_ERRSPACE) { tmpFolder = new SFOLDER; tmpFolder->m_iImageIndex = 4; tmpFolder->m_iIndent = 2; tmpFolder->m_sFolderName = tmpStr; tmpFolder->m_sPathName = szPath; } // Since we have "My Computer" add the drive list underneath. int drive, curdrive; curdrive = _getdrive(); // If we can switch to the drive, it exists. for(drive = 1; drive <= 26; drive++) { if(!_chdrive(drive)) { CString sDriveLetter; sDriveLetter.Format("%c:", drive + 'A' - 1); iSubAddedItem = AddString(sDriveLetter); // Set folder name/text if(iSubAddedItem != CB_ERRSPACE) { m_pFolder = new SFOLDER; CString sTmpDrvLetter; sTmpDrvLetter = sDriveLetter; sTmpDrvLetter += "//"; tmpPath += ";"; tmpPath += sTmpDrvLetter; UINT uiRet = GetDriveType(sTmpDrvLetter); switch(uiRet) { case DRIVE_REMOVABLE: m_pFolder->m_iImageIndex = 5; break; case DRIVE_REMOTE: m_pFolder->m_iImageIndex = 7; break; case DRIVE_CDROM: m_pFolder->m_iImageIndex = 6; break; case DRIVE_FIXED: m_pFolder->m_iImageIndex = 4; sLocalHardDrives += ";"; sLocalHardDrives += sDriveLetter; break; default: m_pFolder->m_iImageIndex = 4; } m_pFolder->m_iIndent = 2; m_pFolder->m_sFolderName = sDriveLetter; m_pFolder->m_sPathName = sDriveLetter; SetItemDataPtr(iSubAddedItem, m_pFolder); } } } _chdrive(curdrive); if(iTmpAddedItem != CB_ERRSPACE) { // Remove the beginning colon sLocalHardDrives.Delete(0, 1); tmpFolder->m_sPathName = sLocalHardDrives; tmpFolder->m_sFolderName += " ("; tmpFolder->m_sFolderName += sLocalHardDrives; tmpFolder->m_sFolderName += ")"; SetItemDataPtr(iTmpAddedItem, tmpFolder); } if (iMainAddedItem != CB_ERRSPACE) { tmpPath.Delete(0,1); tmpMainFolder->m_sPathName = tmpPath; SetItemDataPtr(iMainAddedItem, (void*)tmpMainFolder); } } } // Set initialized flag m_bInitialized = true; }

你可能感兴趣的:(c,list,null,fonts)