Open the file under the specified path, unlimited file name

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);
				}
				else																									
					sname = name;																		
				asmname.push_back(sname);
			}
		}
	} 

	sort(asmname.begin(),asmname.end());
	asmname.erase( unique(asmname.begin(),asmname.end()), asmname.end() );

	return 1;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值