2
0
Эх сурвалжийг харах

Quick.Console

Runcommand return exit code
Unknown 6 жил өмнө
parent
commit
ef03ce8fdc

+ 6 - 4
Quick.Console.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.9
   Version     : 1.9
   Created     : 10/05/2017
   Created     : 10/05/2017
-  Modified    : 29/03/2019
+  Modified    : 22/05/2019
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -213,7 +213,7 @@ type
   {$ENDIF}
   {$ENDIF}
   procedure ConsoleWaitForEnterKey;
   procedure ConsoleWaitForEnterKey;
   {$IFDEF MSWINDOWS}
   {$IFDEF MSWINDOWS}
-  procedure RunConsoleCommand(const aCommand, aParameters : String; CallBack : TOutputProc<PAnsiChar> = nil; OutputLines : TStrings = nil);
+  function RunConsoleCommand(const aCommand, aParameters : String; CallBack : TOutputProc<PAnsiChar> = nil; OutputLines : TStrings = nil) : Cardinal;
   procedure InitConsole;
   procedure InitConsole;
   {$ENDIF}
   {$ENDIF}
 
 
@@ -566,7 +566,7 @@ begin
   SetConsoleTextAttribute(hStdOut, DefConsoleColor);
   SetConsoleTextAttribute(hStdOut, DefConsoleColor);
   TextAttr := DefConsoleColor;
   TextAttr := DefConsoleColor;
   {$ELSE}
   {$ELSE}
-  TextColor(DefConsoleColor);
+  TextColor(ccLightGray);
   TextBackground(ccBlack);
   TextBackground(ccBlack);
   {$ENDIF}
   {$ENDIF}
 end;
 end;
@@ -795,7 +795,7 @@ end;
 {$ENDIF}
 {$ENDIF}
 
 
 {$IFDEF MSWINDOWS}
 {$IFDEF MSWINDOWS}
-procedure RunConsoleCommand(const aCommand, aParameters : String; CallBack : TOutputProc<PAnsiChar> = nil; OutputLines : TStrings = nil);
+function RunConsoleCommand(const aCommand, aParameters : String; CallBack : TOutputProc<PAnsiChar> = nil; OutputLines : TStrings = nil) : Cardinal;
 const
 const
   CReadBuffer = 2400;
   CReadBuffer = 2400;
 var
 var
@@ -810,6 +810,7 @@ var
   dRunning: DWORD;
   dRunning: DWORD;
   dAvailable: DWORD;
   dAvailable: DWORD;
 begin
 begin
+  Result := 0;
   saSecurity.nLength := SizeOf(Windows.TSecurityAttributes);
   saSecurity.nLength := SizeOf(Windows.TSecurityAttributes);
   saSecurity.bInheritHandle := true;
   saSecurity.bInheritHandle := true;
   saSecurity.lpSecurityDescriptor := nil;
   saSecurity.lpSecurityDescriptor := nil;
@@ -855,6 +856,7 @@ begin
           CloseHandle(piProcess.hThread);
           CloseHandle(piProcess.hThread);
         end;
         end;
       end;
       end;
+      GetExitCodeProcess(piProcess.hProcess,Result);
     finally
     finally
       CloseHandle(hRead);
       CloseHandle(hRead);
       CloseHandle(hWrite);
       CloseHandle(hWrite);