我是用ShellExecute调用了一个外部exe程序,这个程序运行需要些时间,我如何知道这个Exe执行完了呢?(100分)

  • 主题发起人 xiaoyue_a
  • 开始时间
X

xiaoyue_a

Unregistered / Unconfirmed
GUEST, unregistred user!
我是用ShellExecute调用了一个外部exe程序,这个程序运行需要些时间,我如何知道这个Exe执行完了呢?大家指教下,先谢过各位了!!!
 
据说原来的帖子里有,可是没法找了啊,大家指教下!!!
 
function ExecuteAndWaitProcess(<br>&nbsp; &nbsp;const ACmdLine &nbsp;: string;<br>&nbsp; &nbsp;const ACurrDir &nbsp;: string = ''<br>&nbsp; &nbsp;):Boolean;<br>var<br>&nbsp;SI: TStartupInfo;<br>&nbsp;PI: TProcessInformation;<br>begin<br>&nbsp;FillChar(SI, SizeOf(SI), 0);<br>&nbsp;SI.cb := SizeOf(SI);<br>&nbsp;SI.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;<br>&nbsp;SI.wShowWindow := SW_HIDE;<br>&nbsp;Screen.Cursor := crHourGlass;<br>&nbsp;try<br>&nbsp; &nbsp;CreateProcess(<br>&nbsp; &nbsp; &nbsp; &nbsp;nil,<br>&nbsp; &nbsp; &nbsp; &nbsp;PChar(ACmdLine),<br>&nbsp; &nbsp; &nbsp; &nbsp;nil,<br>&nbsp; &nbsp; &nbsp; &nbsp;nil,<br>&nbsp; &nbsp; &nbsp; &nbsp;True,<br>&nbsp; &nbsp; &nbsp; &nbsp;0,<br>&nbsp; &nbsp; &nbsp; &nbsp;nil,<br>&nbsp; &nbsp; &nbsp; &nbsp;PChar(ACurrDir),<br>&nbsp; &nbsp; &nbsp; &nbsp;SI,<br>&nbsp; &nbsp; &nbsp; &nbsp;PI);<br>&nbsp; &nbsp;WaitForSingleObject(PI.hProcess, INFINITE);<br>&nbsp; &nbsp;Result &nbsp;:= &nbsp;True;<br>&nbsp;finally<br>&nbsp; &nbsp;Screen.Cursor := crDefault;<br>&nbsp;end;<br>end;<br><br><br><br>调用方法 :<br>ExecuteAndWaitProcess( 'e:/xxx/yyy.exe','e:/xxx/') ;
 
多谢了,大牛 哥哥 呵呵
 
顶部