shellexecute 和 createprocess,运行一个程序直到其结束,偷偷运行一个程序。。。
2009-02-10 17:47
671 查看
如何打开一个应用程序?
或
正如您所看到的,我并没有传递程序的完整路径。
Q: 如何打开一个同系统程序相关连的文档?
Q: 如何打开一个网页?
Q: 如何激活相关程序,发送EMAIL?
Q: 如何用系统打印机打印文档?
Q: 如何用系统查找功能来查找指定文件?
Q: 如何启动一个程序,直到它运行结束?
或:
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);
相关文章推荐
- shellexecute 和 createprocess,运行一个程序直到其结束,偷偷运行一个程序
- shellexecute 和 createprocess,运行一个程序直到其结束
- java程序中,如何安全的结束一个正在运行的线程?
- 函数——ShellExecute()——运行一个外部程序
- java程序中,如何安全的结束一个正在运行的线程?
- WinExec 、ShellExecute和CreateProcess 程序中运行别的程序或者打开网页、文件
- 局部QEventLoop帮助QWidget不消失(也就是有一个局部事件循环始终在运行,导致程序被卡住那里,但仍可以接受事件。说白了就是有一个while语句死活不肯退出,直到收到退出信号)
- 编写一个程序,循环从键盘接收一批学生的某门课的成绩,并依次保存在数组score的相应元素中,直到输入的成绩为999时结束。
- 如何调用一个程序,等待运行结束,并知晓程序运行成功与否:ShellExecuteEx;WaitForSingleObject;GetExitCodeProcess(C代码)
- 如何调用一个程序,等待运行结束,并知晓程序运行成功与否:ShellExecuteEx;WaitForSingleObject;GetExitCodeProcess(C代码)
- VC启动一个程序并等待运行结束
- java程序中,如何安全的结束一个正在运行的线程?
- 控制一个 Java 程序运行生命周期结束前不能再次被执行
- java程序中,如何安全的结束一个正在运行的线程?interrupt()
- 我在delphi中用shellExecute启动了一个程序(ftp);然后想做一个等待,只到ftp进程结束,再继续下面的操作,请问如何监控这个进程是否已结束?
- java程序中,如何安全的结束一个正在运行的线程?
- windows运行一个程序并等待其结束。
- 7.1在窗口(宽300,高200)中添加一个面板,面板的背景色为绿色,窗口在屏幕中央,不允许改变其大小,关闭窗口时程序结束运行
- java程序中,如何安全的结束一个正在运行的线程
- 保证当前只有一个程序在运行