Getting the screen resolution

I agree that HiDPI has not been solved well by Microsoft.

Here is the code that i use on Windows. Maybe it helps:

char size = 1;//default  100%
                long maxx = (int)GetSystemMetrics(SM_CXSCREEN);
                long maxy = (int)GetSystemMetrics(SM_CYSCREEN);
                
                HDC screen = GetDC(0);
                int dpiX = GetDeviceCaps(screen, LOGPIXELSX);
                float scaleX = (float)(dpiX) / 96.f;//desktop skaliering auslesen
                int dpiY = GetDeviceCaps(screen, LOGPIXELSY);
                float scaleY = (float)(dpiY) / 96.f;
                ReleaseDC(0, screen);
                
                if ((scaleX != 0) && (scaleY != 0))
                {
                    float guix = 1008;
                    float guiy = 522;
     
                    if (((float)(maxx) / scaleX > guix * 2) && ((float)(maxy) / scaleY > guiy * 2)) size = 5;// 200%
                   
                    return size;
                }