Thema: IsConsole?

Einzelnen Beitrag anzeigen

null33

Registriert seit: 26. Aug 2015
11 Beiträge
 
#3

AW: IsConsole?

  Alt 21. Mär 2016, 07:55
Von Stackoverflow:
Delphi-Quellcode:
function IAmAConsoleApp: Boolean;
var
  Stdout: THandle;
begin
  Stdout := GetStdHandle(Std_Output_Handle);
  Win32Check(Stdout <> Invalid_Handle_Value);
  Result := Stdout <> 0;
end;
Zitat:
Call GetStdHandle(Std_Output_Handle). If it succeeds and returns zero, then there is no console to write to. Other return values indicate that a console is attached to the process, so you can write to it (although the console may not be the most desirable place to log messages in a console program since they'll interfere with the normal output).
  Mit Zitat antworten Zitat