以前只知道用CFileDialog打开一个文件,却不知怎么打开一个目录。
后来找了点源码
void CDlgSetStaticPath::OnButtonSelectPath()
{
BROWSEINFO bi;
ITEMIDLIST *pidl;
char dir[256]="";
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 )
{
dir[0] = 0;
}
if (SHGetPathFromIDList( pidl, dir ))
{
m_strPathName = dir;
UpdateData(FALSE);
}
}