Win32API的ShellExtension外壳扩展接口提供了这种途径。下面是一段用C语言
编写的程序,可以显示上图所示的对话框。voidSelectDirDlg(charDir[])
{
BROWSEINFObi;
ITEMIDLIST*pidl;
bi.hwndOwner=NULL;
bi.pidlRoot=NULL;
bi.pszDisplayName=Dir;
bi.lpszTitle="Selectadirectory";
bi.ulFlags=BIF_RETURNONLYFSDIRS;
bi.lpfn=NULL;
bi.lParam=0;
bi.iImage=0;
pidl=SHBrowseForFolder(&bi);/*Display"SelectFolder"dia
logbox,Getthe
foldernameandconvertit
intoaITEMLIST
datastructure.*/
if(pidl==NULL)
Dir[0]=0;
if(!SHGetPathFromIDList(pidl,Dir))/*Retrievefoldernam
efromITEMLIST
structure.*/
Dir[0]=0;
}
编写的程序,可以显示上图所示的对话框。voidSelectDirDlg(charDir[])
{
BROWSEINFObi;
ITEMIDLIST*pidl;
bi.hwndOwner=NULL;
bi.pidlRoot=NULL;
bi.pszDisplayName=Dir;
bi.lpszTitle="Selectadirectory";
bi.ulFlags=BIF_RETURNONLYFSDIRS;
bi.lpfn=NULL;
bi.lParam=0;
bi.iImage=0;
pidl=SHBrowseForFolder(&bi);/*Display"SelectFolder"dia
logbox,Getthe
foldernameandconvertit
intoaITEMLIST
datastructure.*/
if(pidl==NULL)
Dir[0]=0;
if(!SHGetPathFromIDList(pidl,Dir))/*Retrievefoldernam
efromITEMLIST
structure.*/
Dir[0]=0;
}