Delphi 7: how to execute shell command and check the result?

前端 未结 6 426
一整个雨季
一整个雨季 2021-01-01 08:28

I\'m using Delphi 7 and can\'t predict the target version of Windows.

I need to create a database (probably MySql, but might be something else) and define some table

6条回答
  •  臣服心动
    2021-01-01 08:39

    Use DSiExecuteAndCapture from DSiWin32:

    var
      exitCode: integer;
      output  : TStringList;
    begin
      output := TStringList.Create;
      try
        if DSiExecuteAndCapture('mysql --version', output, '', exitCode) = 0 then
          Log(Format('error %d, cannot start', [GetLastError])) 
        else begin
          // check exitCode and output
        end;
      finally FreeAndNil(output); end;
    end;
    

提交回复
热议问题