1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| type
TCmdThread = class(TTread)
private
FCmdDirectory: string;
FCmdName: string;
FCmdParam: string;
FAsyncResult: Boolean;
FExitCode: Int64;
FOutputText: string;
FErrorText: string;
protected
procedure Execute; override;
public
constructor Create(const CmdDirectory, CmdName, CmdParam: string); reintroduce;
property AsyncResult: Boolean read FAsyncResult;
property ExitCode: Int64 read FExitCode;
property OutputText: string read FOutputText;
property ErrorText: string read FErrorText;
end;
constructor TCmdThread.Create(const CmdDirectory, CmdName, CmdParam: string);
begin
inherited Create(True);
FCmdDirectory := CmdDirectory;
FCmdName := CmdName;
FCmdParam := CmdParam;
Resume();
end;
procedure TCmdThread.Execute;
var
tmpExitCode: Int64;
tmpOutputText: string;
tmpErrorText: string;
begin
FAsyncResult := CallCmd(FCmdDirectory, FCmdName, FCmdParam, tmpExitCode, tmpOutputText, tmpErrorText);
FExitCode := tmpExitCode;
FOutputText := tmpOutputText;
FErrorText := tmpErrorText;
Terminated := True;
end; |
Partager