Visible property toegevoegd aan TProcess
This commit is contained in:
parent
ec1474ee14
commit
34eb23ccff
@ -10,6 +10,7 @@ type
|
|||||||
private
|
private
|
||||||
FEnvironment: TStrings;
|
FEnvironment: TStrings;
|
||||||
FCommandLine: String;
|
FCommandLine: String;
|
||||||
|
FVisible: Boolean;
|
||||||
FWorkingPath: String;
|
FWorkingPath: String;
|
||||||
protected
|
protected
|
||||||
function BuildEnvironment(): String;
|
function BuildEnvironment(): String;
|
||||||
@ -25,6 +26,7 @@ type
|
|||||||
|
|
||||||
property CommandLine: String read FCommandLine write FCommandLine;
|
property CommandLine: String read FCommandLine write FCommandLine;
|
||||||
property Environment: TStrings read FEnvironment;
|
property Environment: TStrings read FEnvironment;
|
||||||
|
property Visible: Boolean read FVisible write FVisible;
|
||||||
property WorkingPath: String read FWorkingPath write FWorkingPath;
|
property WorkingPath: String read FWorkingPath write FWorkingPath;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -40,6 +42,7 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
FEnvironment := TStringList.Create();
|
FEnvironment := TStringList.Create();
|
||||||
|
FVisible := False;
|
||||||
FWorkingPath := GetCurrentDir();
|
FWorkingPath := GetCurrentDir();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -104,6 +107,9 @@ var
|
|||||||
startupInfo: TStartupInfo;
|
startupInfo: TStartupInfo;
|
||||||
writePipe: Cardinal;
|
writePipe: Cardinal;
|
||||||
bytesRead: Cardinal;
|
bytesRead: Cardinal;
|
||||||
|
newConsole: Boolean;
|
||||||
|
consoleOutput: THandle;
|
||||||
|
bytesWritten: Cardinal;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -133,15 +139,33 @@ begin
|
|||||||
CloseHandle(writePipe);
|
CloseHandle(writePipe);
|
||||||
writePipe := 0;
|
writePipe := 0;
|
||||||
|
|
||||||
GetMem(buffer, BufferSize);
|
newConsole := False;
|
||||||
|
consoleOutput := 0;
|
||||||
|
if Visible then
|
||||||
|
begin
|
||||||
|
newConsole := AllocConsole;
|
||||||
|
consoleOutput := GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
end;
|
||||||
|
|
||||||
try
|
try
|
||||||
repeat
|
GetMem(buffer, BufferSize);
|
||||||
ReadFile(readPipe, buffer^, BufferSize, bytesRead, nil);
|
try
|
||||||
if bytesRead > 0 then
|
repeat
|
||||||
AStream.WriteBuffer(buffer^, bytesRead);
|
ReadFile(readPipe, buffer^, BufferSize, bytesRead, nil);
|
||||||
until bytesRead = 0;
|
if bytesRead > 0 then
|
||||||
|
begin
|
||||||
|
AStream.WriteBuffer(buffer^, bytesRead);
|
||||||
|
|
||||||
|
if consoleOutput <> 0 then
|
||||||
|
WriteFile(consoleOutput, buffer^, bytesRead, bytesWritten, nil);
|
||||||
|
end;
|
||||||
|
until bytesRead = 0;
|
||||||
|
finally
|
||||||
|
FreeMem(buffer, BufferSize);
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
FreeMem(buffer, BufferSize);
|
if newConsole then
|
||||||
|
FreeConsole;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
GetExitCodeProcess(processInfo.hProcess, AExitCode);
|
GetExitCodeProcess(processInfo.hProcess, AExitCode);
|
||||||
|
Loading…
Reference in New Issue
Block a user