深入浅出ShellExecute
2024-10-14 04:52:46
Q: 如何打开一个应用程序?
ShellExecute(this->m_hWnd,"open","calc.exe","","", SW_SHOW );
或
ShellExecute(this->m_hWnd,"open","notepad.exe", "c:\\MyLog.log","",SW_SHOW );
正如您所看到的,我并没有传递程序的完整路径。
Q: 如何打开一个同系统程序相关连的文档?
ShellExecute(this->m_hWnd,"open", "c:\\abc.txt","","",SW_SHOW );
Q: 如何打开一个网页?
ShellExecute(this->m_hWnd,"open", "http://www.google.com","","", SW_SHOW );
Q: 如何激活相关程序,发送EMAIL?
ShellExecute(this->m_hWnd,"open", "mailto:nishinapp@yahoo.com","","", SW_SHOW );
Q: 如何用系统打印机打印文档?
ShellExecute(this->m_hWnd,"print", "c:\\abc.txt","","", SW_HIDE);
Q: 如何用系统查找功能来查找指定文件?
ShellExecute(m_hWnd,"find","d:\\nish", NULL,NULL,SW_SHOW);
Q: 如何启动一个程序,直到它运行结束?
SHELLEXECUTEINFO ShExecInfo = {0}; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; ShExecInfo.hwnd = NULL; ShExecInfo.lpVerb = NULL; ShExecInfo.lpFile = "c:\\MyProgram.exe"; ShExecInfo.lpParameters = ""; ShExecInfo.lpDirectory = NULL; ShExecInfo.nShow = SW_SHOW; ShExecInfo.hInstApp = NULL; ShellExecuteEx(&ShExecInfo); WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
或:
PROCESS_INFORMATION ProcessInfo; STARTUPINFO StartupInfo; //This is an [in] parameter ZeroMemory(&StartupInfo, sizeof(StartupInfo)); StartupInfo.cb = sizeof StartupInfo ; //Only compulsory field if(CreateProcess("c:\\winnt\\notepad.exe", NULL, NULL,NULL,FALSE,0,NULL, NULL,&StartupInfo,&ProcessInfo)) { WaitForSingleObject(ProcessInfo.hProcess,INFINITE); CloseHandle(ProcessInfo.hThread); CloseHandle(ProcessInfo.hProcess); } else { MessageBox("The process could not be started..."); }
Q: 如何显示文件或文件夹的属性?
SHELLEXECUTEINFO ShExecInfo ={0}; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST ; ShExecInfo.hwnd = NULL; ShExecInfo.lpVerb = "properties"; ShExecInfo.lpFile = "c:\\"; //can be a file as well ShExecInfo.lpParameters = ""; ShExecInfo.lpDirectory = NULL; ShExecInfo.nShow = SW_SHOW; ShExecInfo.hInstApp = NULL; ShellExecuteEx(&ShExecInfo);
最新文章
- ng-selected ng-change
- IntelliJ IDEA13.1.3+Scala2.11.1环境搭建
- java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntim [问题点数:40分,结帖人wangxiaohua_001]
- sed命令查找<;media/msm_cam_sensor.h>;替换为";len_msm_cam_sensor.h";
- 微软CEO史蒂夫&#183;鲍尔默(Steve Ballmer)在12个月内退休
- 【转】C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
- OpenCV原则解读HAAR+Adaboost
- 团队作业4——第一次项目冲刺(Alpha版本) 日志集合处
- linux系统下安装tomcat服务器
- Echart横坐标时间轴滑动
- Windows上的程序员神器Cmder
- vue项目启动时将localhost替换成指定ip地址
- JMeter_方案上架,遇到的问题及解决
- C#语句从MySQL中简单的读取数据库信息
- LeetCode--No.013 Roman to Integer
- 项目Alpha冲刺--1/10
- AngularJS 模块及provide
- Golang之字符串格式化
- servlet-servletContext网站计数器
- js多条件if语句简写发生Uncaught SyntaxError: Unexpected token }