怎样等待程序运行结束(200分)

  • 主题发起人 主题发起人 wghua
  • 开始时间 开始时间
W

wghua

Unregistered / Unconfirmed
GUEST, unregistred user!
在调用一个外部程序后(如LHA.EXE),怎样等待程序运行结束后,才进行<br>下一步动作?
 
传递消息!?
 
我要在程序中等解压(lha.exe)完后,再进一步处理。
 
用createprocess创建进程,wairforsingleobject等待结束
 
<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; sCommandLine: string;<br>&nbsp; bCreateProcess: boolean;<br>&nbsp; lpStartupInfo: TStartupInfo;<br>&nbsp; lpProcessInformation: TProcessInformation;<br>begin<br>&nbsp; sCommandLine := 'D:/TEMP/TEST.EXE';<br>&nbsp; // 填? StartupInfo<br>&nbsp; FillChar(lpStartupInfo, Sizeof(TStartupInfo), #0);<br>&nbsp; lpStartupInfo.cb := Sizeof(TStartupInfo);<br>&nbsp; lpStartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br>&nbsp; lpStartupInfo.wShowWindow := SW_NORMAL;<br><br>&nbsp; bCreateProcess := CreateProcess(nil, PChar(sCommandLine),<br>&nbsp; &nbsp; nil, nil, True, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,<br>&nbsp; &nbsp; nil, nil, lpStartupInfo, lpProcessInformation);<br>&nbsp; if bCreateProcess then &nbsp; &nbsp; &nbsp;//等外部进程的结束<br>&nbsp; &nbsp; WaitForSingleObject(lpProcessInformation.hProcess, INFINITE);<br>end;<br>
 
谢了,特别是Victortim
 
后退
顶部