Search code examples
cwindowsmingwscreen-resolution

Windows Get Screen Resolution in C


Using plain C, (not C++ / C# / Objective-C) how do I get the screen resolution in Windows?

My compiler is MingW (not sure if relevant). All solutions I have found online are for C++ or some other C variant.


Solution

  • Use GetSystemMetrics()

    DWORD dwWidth = GetSystemMetrics(SM_CXSCREEN);
    DWORD dwHeight = GetSystemMetrics(SM_CYSCREEN);