Explorar o código

Quick.Console

Runcommand return exit code
Unknown %!s(int64=6) %!d(string=hai) anos
pai
achega
ef03ce8fdc
Modificáronse 1 ficheiros con 6 adicións e 4 borrados
  1. 6 4
      Quick.Console.pas

+ 6 - 4
Quick.Console.pas

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