zoukankan      html  css  js  c++  java
  • delphi执行一个外部程序,当外部程序结束后,delphi程序立即响应

    procedure TForm1.Button1Click(Sender: TObject);  
    var  
      SEInfo: TShellExecuteInfo;  
      ExitCode: DWORD;  
      ExecuteFile, ParamString, StartInString: string;  
    begin  
      ExecuteFile := 'c:\Windows\system32\Calc.exe';  
      FillChar(SEInfo, SizeOf(SEInfo), #0);  
      SEInfo.cbSize := SizeOf(TShellExecuteInfo);  
      with SEInfo do begin  
        fMask := SEE_MASK_NOCLOSEPROCESS;  
        Wnd := Application.Handle;  
        lpFile := PChar(ExecuteFile);  
        //ParamString can contain the application parameters  
    //    lpParameters := PChar(ParamString);  
        //StartInString specifies the name of the working directory.if ommited, the current directory is used.  
    //    lpDirectory := PChar(StartInString);  
        nShow := SW_SHOWNORMAL;  
      end;  
      if ShellExecuteEx(@SEInfo) then  
      begin  
        repeat  
          Application.ProcessMessages;  
          GetExitCodeProcess(SEInfo.hProcess, ExitCode);  
          if ExitCode = STILL_ACTIVE then Sleep(500);  
        until (ExitCode <> STILL_ACTIVE) or Application.Terminated;  
        ShowMessage('Calculator terminated');  
      end  
      else  
        ShowMessage('Error starting Calc!');  
    end;  
  • 相关阅读:
    Kubernetes 命令行工具之kubctl
    新一代数据库之Etcd 简介
    算法题 打家劫舍(动态规划)
    算法题 位1的个数
    Class强制类型转换
    算法题 阶乘后的零
    算法题 Excel表列序号
    多数元素
    有序数组两数之和
    一杯果汁和一杯水的故事
  • 原文地址:https://www.cnblogs.com/railgunman/p/1889730.html
Copyright © 2011-2022 走看看