📄 subject_22451.htm
字号:
<p>
序号:22451 发表者:金枪鱼 发表日期:2002-11-26 10:10:08
<br>主题:请问如果知道一个控制台程序已经执行完毕
<br>内容:我想在VC++程序中,通过ShellExecute函数启动一个Console类型的程序,我现在如果在程序中知道这个程序已经执行完毕。<BR>请高手指点。
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:徐景周 回复日期:2002-11-26 10:31:12
<br>内容:参看:<BR>http://www.copathway.com/itbookreview/view_paper.asp?paper_id=326<BR><BR>如用下法:<BR>: 如何启动一个程序,直到它运行结束?<BR>SHELLEXECUTEINFO ShExecInfo = {0};<BR>ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);<BR>ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;<BR>ShExecInfo.hwnd = NULL;<BR>ShExecInfo.lpVerb = NULL;<BR>ShExecInfo.lpFile = "c:\\MyProgram.exe"; <BR>ShExecInfo.lpParameters = ""; <BR>ShExecInfo.lpDirectory = NULL;<BR>ShExecInfo.nShow = SW_SHOW;<BR>ShExecInfo.hInstApp = NULL; <BR>ShellExecuteEx(&ShExecInfo);<BR>WaitForSingleObject(ShExecInfo.hProcess,INFINITE);<BR>或:<BR>PROCESS_INFORMATION ProcessInfo; <BR>STARTUPINFO StartupInfo; //This is an [in] parameter<BR>ZeroMemory(&StartupInfo, sizeof(StartupInfo));<BR>StartupInfo.cb = sizeof StartupInfo ; //Only compulsory field<BR>if(CreateProcess("c:\\winnt\\notepad.exe", NULL, <BR> NULL,NULL,FALSE,0,NULL,<BR> NULL,&StartupInfo,&ProcessInfo))<BR>{ <BR> WaitForSingleObject(ProcessInfo.hProcess,INFINITE);<BR> CloseHandle(ProcessInfo.hThread);<BR> CloseHandle(ProcessInfo.hProcess);<BR>} <BR>else<BR>{<BR> MessageBox("The process could not be started...");<BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:金枪鱼 回复日期:2002-11-26 14:11:38
<br>内容:万分感动!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -