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