我设法将编译器设置为在项目选项中使用以下指令构建/运行项目时执行另一个程序:

call program.exe param1 param2

问题在于编译器执行“ program.exe”,并等待终止,然后项目可执行文件为运行。

我要问的是:如何将编译器设置为并行运行两个可执行文件,而无需等待后建筑事件中的一个可执行文件?

提前致谢

有帮助吗?

解决方案

我不知道IDE如何设法等待“ start”启动的过程终止,但是在您自己的程序启动器中最简单地将“ CreateProcess”调用。

编译STH。喜欢;

program starter;

{$APPTYPE CONSOLE}

uses
  sysutils, windows;

var
  i: Integer;
  CmdLine: string;
  StartInfo: TStartupInfo;
  ProcInfo: TProcessInformation;
begin
  try
    if ParamCount > 0 then begin
      CmdLine := '';
      for i := 1 to ParamCount do
        CmdLine := CmdLine + ParamStr(i) + ' ';
      ZeroMemory(@StartInfo, SizeOf(StartInfo));
      StartInfo.cb := SizeOf(StartInfo);
      ZeroMemory(@ProcInfo, SizeOf(ProcInfo));
      if not CreateProcess(nil, PChar(CmdLine), nil, nil, False,
                      NORMAL_PRIORITY_CLASS, nil, nil, StartInfo, ProcInfo) then
        raise Exception.Create(Format('Failed to run: %s'#13#10'Error: %s'#13#10,
                            [CmdLine, SysErrorMessage(GetLastError)]));
    end;
  except
    on E:Exception do begin
      Writeln(E.ClassName + ', ' +  E.Message);
      Writeln('... [Enter] to dismiss ...');
      Readln(Input);
    end;
  end;
end.

然后在后建筑中排名:

"X:\...\starter.exe" "X:\...\program.exe" param1 param2

其他提示

而不是呼叫program.exe,请使用start program.exe

创建一个蝙蝠文件。正如艾伦(Alan)所建议的那样,将很少的命令放在那里:

start program.exe param1 param2
start program.exe param1 param2
start program.exe param1 param2 
start program.exe param1 param2

然后调用此蝙蝠文件。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top