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;
}
博客介绍了Win32 API的ShellExtension外壳扩展接口,并给出一段用C语言编写的程序,该程序可显示特定对话框。程序中对BROWSEINFO结构体进行了初始化,通过SHBrowseForFolder函数显示对话框并获取文件夹名,再用SHGetPathFromIDList函数从数据结构中提取文件夹名。
2536

被折叠的 条评论
为什么被折叠?



