请问,在 WINDOWS 调用一个 do S 命令,我怎么能判断 do S 命令已结束并且 do S 窗口已关闭? (100分)

  • 主题发起人 主题发起人 白海清
  • 开始时间 开始时间
早就有人贴过了。<br>function WinExecAndWait32(FileName:String; Visibility : integer):integer;<br>var<br>&nbsp; zAppName:array[0..512] of char;<br>&nbsp; zCurDir:array[0..255] of char;<br>&nbsp; WorkDir:String;<br>&nbsp; StartupInfo:TStartupInfo;<br>&nbsp; ProcessInfo:TProcessInformation;<br>begin<br>&nbsp; StrPCopy(zAppName,FileName);<br>&nbsp; GetDir(0,WorkDir);<br>&nbsp; StrPCopy(zCurDir,WorkDir);<br>&nbsp; FillChar(StartupInfo,Sizeof(StartupInfo),#0);<br>&nbsp; StartupInfo.cb := Sizeof(StartupInfo);<br><br>&nbsp; StartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br>&nbsp; StartupInfo.wShowWindow := Visibility;<br>&nbsp; if not CreateProcess(nil,<br>&nbsp; &nbsp; zAppName, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ pointer to command line string }<br>&nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to process security attributes }<br>&nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to thread security attributes }<br>&nbsp; &nbsp; false, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { handle inheritance flag }<br>&nbsp; &nbsp; CREATE_NEW_CONSOLE or &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ creation flags }<br>&nbsp; &nbsp; NORMAL_PRIORITY_CLASS,<br>&nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to new environment block }<br>&nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to current directory name }<br>&nbsp; &nbsp; StartupInfo, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to STARTUPINFO }<br>&nbsp; &nbsp; ProcessInfo) then Result := -1 { pointer to PROCESS_INF }<br><br>&nbsp; else begin<br>&nbsp; &nbsp; WaitforSingleObject(ProcessInfo.hProcess,INFINITE);<br>&nbsp; &nbsp; GetExitCodeProcess(ProcessInfo.hProcess,Result);<br>&nbsp; end;<br>end;
 
lml:我以前用过这种方法,但它不能自动关闭DOS窗口,当手动关闭后它才能捕捉到DOS窗口<br>已关闭.请大家再帮一次忙...<br>对于wangxd 说的'listen'我没有用过是否能详细说一下? &nbsp;
 
&gt;&gt;对于wangxd 说的'listen'我没有用过是否能详细说一下? &nbsp; <br>I faint
 
后退
顶部