如何执行外部程序,并一直等到它结束,在线等

解决方案 »

  1.   

    这样的问题问过无数回了,查以前的贴子看吧。
    ------------------------------------
    《CSDN论坛新助手 CSDN's forum Explorer》,支持最新改版论坛,回复、浏览“方便”,“快捷”!
    下载地址:http://www.seeyou.com.cn/CoolSlob/CSDNExplorer.exe
      

  2.   

    function WinExecAndWait32(FileName:String; Visibility : integer):integer; 
    var 
      zAppName:array[0..512] of char; 
      zCurDir:array[0..255] of char; 
      WorkDir:String; 
      StartupInfo:TStartupInfo; 
      ProcessInfo:TProcessInformation; 
    begin 
      StrPCopy(zAppName,FileName); 
      GetDir(0,WorkDir); 
      StrPCopy(zCurDir,WorkDir); 
      FillChar(StartupInfo,Sizeof(StartupInfo),#0); 
      StartupInfo.cb := Sizeof(StartupInfo);   StartupInfo.dwFlags := STARTF_USESHOWWINDOW; 
      StartupInfo.wShowWindow := Visibility; 
      if not CreateProcess(nil, 
        zAppName,                       { pointer to command line string } 
        nil,                            { pointer to process security attributes } 
        nil,                            { pointer to thread security attributes } 
        false,                          { handle inheritance flag } 
        CREATE_NEW_CONSOLE or           { creation flags } 
        NORMAL_PRIORITY_CLASS, 
        nil,                            { pointer to new environment block } 
        nil,                            { pointer to current directory name } 
        StartupInfo,                    { pointer to STARTUPINFO } 
        ProcessInfo) then Result := -1 { pointer to PROCESS_INF }   else begin 
        WaitforSingleObject(ProcessInfo.hProcess,INFINITE); 
        GetExitCodeProcess(ProcessInfo.hProcess,Result); 
      end; 
    end;
      

  3.   

    TO:gonglincheng(森林)
    能否对给予的程序给一些注释,看不明白