Open the file under the specified path, unlimited file name

来源:互联网 发布:霍金人工智能开场白 编辑:程序博客网 时间:2024/05/22 15:03
void BtnOpenSpecifile(){SHELLEXECUTEINFO shell = { sizeof(shell) };shell.fMask = SEE_MASK_FLAG_DDEWAIT;shell.lpVerb = L"open";CString helppath,fpath;fpath.Format(L"%s\\help",lzy_dir);vector<CString> pdfnames;if (!PathIsDirectory(fpath)){AfxMessageBox(L"没有找到帮助说明,请检查!");return PRO_TK_E_NOT_FOUND;}_Finder(fpath,L"pdf",pdfnames);if (pdfnames.empty()){AfxMessageBox(L"没有找到帮助说明,请检查!");return PRO_TK_E_NOT_FOUND;}helppath.Format(L"%s\\help\\%s",lzy_dir,pdfnames[0]);shell.lpFile = helppath;shell.nShow = SW_SHOWNORMAL;BOOL ret = ShellExecuteEx(&shell);return PRO_TK_NO_ERROR;}


int _Finder(LPCTSTR fpath,CString extension,vector<CString> &asmname)//将路径fpath下的后缀为extension的文件名称保存到asmname中{CFileFind finder;CString strWildcard(fpath);strWildcard += _T("//*.*");BOOL bWorking = finder.FindFile(strWildcard);vector<CString> lf_names;while (bWorking)//遍历文件夹{bWorking = finder.FindNextFile();CString name = finder.GetFileName();int num1 = 0;CString extend1,extend2;num1 = name.Find('.');extend1 = name.Right(name.GetLength() - num1 - 1);extend2 = extend1;int num2 = extend1.Find('.');if (num2 >0){extend2 = extend1.Left(num2);}if(!finder.IsDots())///////////////////////////////////////判断是否为.或..{if (extend2 == extension)//m_ext_now为你要查找的文件扩展名{CString sname;if (num2 !=-1){sname = name.Left(num1+num2+1);}elsesname = name;asmname.push_back(sname);}}} sort(asmname.begin(),asmname.end());asmname.erase( unique(asmname.begin(),asmname.end()), asmname.end() );return 1;}


0 0
原创粉丝点击