环境为VS2008,unicode字符集,walker测试可行。
1、选择目录(参考这里)
- BROWSEINFO bi;
- TCHAR Buffer[512];
- CString dir;
- //初始化入口参数bi开始
- bi.hwndOwner = NULL;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = Buffer;//此参数如为NULL则不能显示对话框
- bi.lpszTitle = _T("选择输出目录");
- bi.ulFlags = BIF_RETURNONLYFSDIRS;
- bi.lpfn = NULL;
- bi.iImage = 0;
- //初始化入口参数bi结束
- LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框
- if(pIDList)//选择到路径(即:点了确定按钮)
- {
- //取得文件夹路径到Buffer里
- SHGetPathFromIDList(pIDList, Buffer);
- dir = Buffer;
- }
- else//取消选择
- {
- return ;
- }
2、选择多个文件(参考这里)
- CFileDialog dlgOpen(TRUE, 0, 0, OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST,
- _T("DB Files(*.mdb;*.accdb)|*.mdb;*.accdb|All Files (*.*)|*.*||"), NULL);
- dlgOpen.m_ofn.lpstrTitle = _T("添加待处理的文件");
- CString filename;
- if(dlgOpen.DoModal() == IDOK)
- {
- POSITION fileNamesPosition = dlgOpen.GetStartPosition();
- while(fileNamesPosition != NULL)
- {
- filename = dlgOpen.GetNextPathName(fileNamesPosition);
- }
- }
- else
- {
- return ;
- }