VC++浏览文件夹

 char DirPath[MAX_PATH];
 BROWSEINFO bi;
 ITEMIDLIST * pidl;

 bi.hwndOwner = NULL;
 bi.pidlRoot = NULL;
 bi.pszDisplayName = Dir;
 bi.lpszTitle = "请选择图片文件夹。";
 bi.ulFlags = BIF_RETURNONLYFSDIRS;
 bi.lpfn = NULL;
 bi.lParam = 0;
 bi.iImage = 0;

 pidl = SHBrowseForFolder(&bi);
 if(pidl == NULL)
  DirPath[0] = 0;
 if(!SHGetPathFromIDList(pidl,Dir))
                DirPath[0] = 0;

 //释放内存
 LPMALLOC pMalloc;
 if (SUCCEEDED(SHGetMalloc(&pMalloc)))
 {
  pMalloc->Free(pidl);
  (void)pMalloc->Release();
 }

你可能感兴趣的:(VC++浏览文件夹)