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

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

 

1
2
3
4
5
6
7
8
9
10
11
12
13
//方法1
    //转换
    //char msg[256];
    //sprintf_s(msg, "start %s", strDir.c_str());
 
    //打开并显示文件夹(windows cmd)
    //system(msg);
<br> //方法2
    //ShellExecute打开一个文件
    //ShellExecute(NULL, "open", "C:\\11.txt", NULL, NULL, SW_SHOWNORMAL);
     
    ////ShellExecute打开并显示文件夹
    ShellExecute(NULL, "open", strDir.c_str(), NULL, NULL, SW_SHOWNORMAL);

  

1
2
3
4
5
6
7
8
9
10
11
12
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 @   曦花  阅读(2060)  评论(0编辑  收藏  举报
(评论功能已被禁用)
点击右上角即可分享
微信分享提示