我一直在尝试使用 <Windows.h> 的函数获取屏幕尺寸GetDeviceCaps(GetDC(NULL), HORZRES),但每当我运行代码时,它总是返回屏幕分辨率的一半。
有谁知道为什么我的电脑会发生这种情况?它在大多数其他显示器上运行良好。
我的屏幕分辨率是 (2736x1824) (surface pro)。
#include <Windows.h>
#include <iostream>
int main()
{
HDC display = GetDC(NULL);
const int x = GetDeviceCaps(display, HORZRES), y = GetDeviceCaps(display, VERTRES); //returns (1368, 912)
std::cout << x << ", " << y << "\n";
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)