win10/win11 获取系统DPI 源码
#include
#include
#include
#pragma comment(lib, "Shcore.lib")
using namespace std;
int main()
{
HWND hWnd = ::GetDesktopWindow();
HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
UINT dpiX = 0, dpiY = 0;
GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY);
dpiX = dpiX * 100 / 96;
dpiY = dpiY * 100 / 96;
cout <<"dpi "<< dpiX << "%" << endl;
system("pause");
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)