Check if a console application is running in full screen mode (Views: 102)


I made a console application that at some point needs to know if it's running in a window or in full screen mode. I looked at Console API calls, but cannot find anything distinctive.


The function IsConsoleFullscreen() works fine with W98 and ME, but not with 2000 (and XP, I presume). The GetConsoleDisplayMode function is also in Win2000 (not documented), at least with service pack 1 and up. To get the test to work on both series of platforms, you have to use LoadLibrary and GetProcAddress:

function IsConsoleFullscreen: Boolean;
  TGetConsoleDisplayMode = function(var lpdwMode: DWORD): Boolean; stdcall;
  Handle: THandle;
  DisplayMode: TGetConsoleDisplayMode;
  W: HWND;
  PID: Cardinal;
  R: TRect;
  CurMode: DWORD;
  PlatFormXP2000: Boolean;
  Result := False;
  PlatFormXP2000 := False;
  Handle := LoadLibrary('kernel32.dll');
  if Handle <> 0 then
    @DisplayMode := GetProcAddress(Handle, 'GetConsoleDisplayMode');
    if @DisplayMode <> nil then
      PlatFormXP2000 := DisplayMode(CurMode);
      if PlatFormXP2000 then
        Result := (CurMode <> 0);
  if not PlatFormXP2000 then
    W := GetForegroundWindow;
    GetWindowThreadProcessId(W, @PID);
    if PID <> GetCurrentProcessID then
    if not IsIconic(W) then
    GetClientRect(W, R);
    Result := (R.Right = 0) and (R.Bottom = 0);

<< Back to main page