ShellExecute打开文件,打开文件夹的用法

转自https://www.cnblogs.com/nxopen2018/p/11070031.html

 

 //方法1
    //转换
    //char msg[256];
    //sprintf_s(msg, "start %s", strDir.c_str());

    //打开并显示文件夹(windows cmd)
    //system(msg);

//方法2 //ShellExecute打开一个文件 //ShellExecute(NULL, "open", "C:\\11.txt", NULL, NULL, SW_SHOWNORMAL); ////ShellExecute打开并显示文件夹 ShellExecute(NULL, "open", strDir.c_str(), NULL, NULL, SW_SHOWNORMAL);

  

		CString strLocalFile = m_temp_path + _T("output.pdf");
		CFileDialog dlg(FALSE, _T("*.pdf"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("PDF Files (*.pdf)|*.pdf||"));
		if(dlg.DoModal() == IDOK)
		{
			strLocalFile = dlg.GetPathName();
			BOOL bRet = TRUE;
			if (bRet)
			{
				CString strFolder = dlg.GetFolderPath();
				ShellExecute( NULL, _T("open"), strFolder, NULL, NULL, SW_SHOWNORMAL);
			}			
		}

  

posted @ 2019-12-17 11:02  曦花  阅读(2003)  评论(0编辑  收藏  举报