WinExec 、ShellExecute和CreateProcess 程序中运行别的程序或者打开网页、文件
来源:互联网 发布:校园导游c语言 编辑:程序博客网 时间:2024/06/05 06:21
</pre><pre name="code" class="cpp">if (WinExec("cale.exe",SW_SHOW)<32){AfxMessageBox("winexec not can't notepad");}if (ShellExecute(NULL,"open","<span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; ">NOTEPAD.EXE</span>",NULL,NULL,SW_SHOW)<(HANDLE)32){AfxMessageBox("shll");}ShellExecute(NULL,"open","d:\\test\\test.exe",NULL,NULL,SW_SHOWNORMAL);TCHAR szCmdLine[]={TEXT("d:\\test\\test.exe")};STARTUPINFO si; //一些必备参数设置memset(&si, 0, sizeof(STARTUPINFO));si.cb = sizeof(STARTUPINFO);si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOW;PROCESS_INFORMATION pi; //必备参数设置结束//lpCommandLine不能写成"d:\\test\\te.exe"常量形式 ,改成 TCHAR szCmdLine[]={"d:\\test\\te.exe"}//lpCommandLine需要改成 TCHAR szCmdLine[]={TEXT("d:\\test\\te.exe")};if(!CreateProcess(NULL,szCmdLine,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi)){AfxMessageBox("fail");}else{AfxMessageBox("success");}
ShellExecute是我们常用的一个API,可以运行程序,打开网页。
ShellExecute(NULL, "open", "http://www.csdn.net", NULL,NULL,SW_SHOWMAXIMIZED);
这样可以打开一个网页,但不是在新IE中打开,改成下面方式时就可以在一个新的IE中打开网页了
ShellExecute(NULL, "open", "IEXPLORE", "http://www.csdn.net", NULL,SW_SHOWMAXIMIZED); //VC6.0版本
VS2008中使用下面的版本:
ShellExecute(NULL, L"open", L"IEXPLORE", L"http://www.csdn.net", NULL,SW_SHOWMAXIMIZED);
结合SysLink控件使用效果更佳!直接在SysLink控件的点击响应函数中加入一句:
ShellExecute(NULL, L"open", L"IEXPLORE", L"http://www.csdn.net", NULL,SW_SHOWMAXIMIZED);
就一切OK了!
0 0
- WinExec 、ShellExecute和CreateProcess 程序中运行别的程序或者打开网页、文件
- VC通过WinExec和ShellExecute打开指定程序或者文件的方法
- MFC 打开外部文件 WinExec,ShellExecute ,CreateProcess
- MFC 打开外部文件 WinExec,ShellExecute ,CreateProcess
- MFC 打开外部文件 WinExec,ShellExecute ,CreateProcess
- WinExec、ShellExecute和CreateProcess
- vc打开文件(ShellExecute和WinExec)
- shellexecute 和 createprocess,运行一个程序直到其结束
- VC WinExec打开指定程序或者文件的方法
- ShellExecute打开我的电脑,打开文件或者程序
- 三个API函数可以运行可执行文件WinExec、ShellExecute和CreateProcess。CreateProcess
- CreateProcess、ShellExecute和WinExec的区
- shellexecute 和 createprocess,运行一个程序直到其结束,偷偷运行一个程序。。。
- WinExec, ShellExecute,CreateProcess
- WinExec, ShellExecute, CreateProcess
- WinExec, ShellExecute, CreateProcess -- (修正)
- WinExec,ShellExecute ,CreateProcess
- ShellExecute, WinExec, CreateProcess
- Cocos2d-x JavaActivity 程序背景透明
- ASCII码排序
- LeetCode 8 Binary Tree Preorder Traversal
- ORACLE中order by造成分页不正确原因分析
- mysql安装图解
- WinExec 、ShellExecute和CreateProcess 程序中运行别的程序或者打开网页、文件
- linux tr命令详解
- 自动缩放TextView 根据字符长度自动缩放
- 插入排序
- Perl语言设计者 Larry Wall 编程原则
- Nginx Location 的语法详解,与简单配置
- 包装类型、装箱拆箱、基本类型速度比较
- 详解Windows下Eclipse CDT 配置C-C++ 编译环境
- Java反射机制