EVC浏览文件夹对话框

1.头文件#include <shlobj.h>

2.库Ceshell.lib

CString strDir; BROWSEINFO bi; LPMALLOC pMalloc = NULL; ZeroMemory(&bi, sizeof(bi)); TCHAR szDisplayName[MAX_PATH]; LPITEMIDLIST pidl; bi.hwndOwner = GetSafeHwnd(); bi.pszDisplayName = szDisplayName; bi.lpszTitle= TEXT("请选择一个文件夹"); bi.ulFlags=BIF_RETURNONLYFSDIRS; pidl=SHBrowseForFolder(&bi); if(pidl) { SHGetPathFromIDList(pidl,szDisplayName); strDir = szDisplayName; CString Str; Str=szDisplayName; Str+="//*.mp3"; GetAllFileInfo(Str); Str=szDisplayName; Str+="//*.wma"; GetAllFileInfo(Str); Str=szDisplayName; Str+="//*.wav"; GetAllFileInfo(Str); ConstructList(); } if(SHGetMalloc(&pMalloc)==NOERROR) pMalloc->Free((void *)pidl);

GetAllFileInfo(LPCWSTR lpFileName) { WIN32_FIND_DATA AlbumData; HANDLE hSearch; bool bFinished=false; CString Str=lpFileName; //开始按搜索条件搜索 hSearch=FindFirstFile(lpFileName,&AlbumData); if(hSearch==INVALID_HANDLE_VALUE) { return; } PathAndFileName[nTotalFileCount]=Str.Left(Str.GetLength()-5); PathAndFileName[nTotalFileCount]+=AlbumData.cFileName; NKDbgPrintfW(L"PathAndFileName[nTotalFileCount]=%s/n",PathAndFileName[nTotalFileCount]); nTotalFileCount++; while(!bFinished&&nTotalFileCount<MAXNUM) { if(!FindNextFile(hSearch,&AlbumData)) { bFinished=true; } else { PathAndFileName[nTotalFileCount]=Str.Left(Str.GetLength()-5); PathAndFileName[nTotalFileCount]+=AlbumData.cFileName; nTotalFileCount++; } } if(!FindClose(hSearch)) { AfxMessageBox(_T("关闭查找句柄失败")); } }

你可能感兴趣的:(EVC浏览文件夹对话框)