Search code examples
cwinapifullscreenmingw32

Failed to create a fuilscreen console window in C


#define _WIN32_WINNT 0x0601
#include <windows.h>

int main() 
{
    HWND StdHandle = GetStdHandle (STD_OUTPUT_HANDLE);
    SetConsoleDisplayMode (StdHandle, CONSOLE_FULLSCREEN_MODE, 0);
    system ("pause");
}

The Community Additions written by Jim Michaels said that if your app requires windows 7, you must add #define _WIN32_WINNT 0x0601 at the top of your files just before the #includes.

But this thread said that Microsoft removed the functionality (WDDM display drivers).

Which is correct?

My aim is to create a fuilscreen console window, but eventually failed. Why?


Solution

  • Windows Seven:

    #include <Windows.h>
    int main()
    {
        HANDLE hStdHandle = GetStdHandle (STD_OUTPUT_HANDLE);
        BOOL bWin32Ret = SetConsoleDisplayMode (hStdHandle, CONSOLE_FULLSCREEN_MODE, 0);
        if ( bWin32Ret == 0 )
        {
            DWORD dwLastError = GetLastError(); // 120
        }
    }
    

    winerror.h excerpt

    // This function is not supported on this system.
    //
    #define ERROR_CALL_NOT_IMPLEMENTED       120L
    

    using #define for _WIN32_WINNT won't change anything.