函数原型:
BOOL EnumDisplaySettings(LPCTSTR lpszDeviceName, DWORD iModeNum, LPDEVMODE lpDevMode);
使用示例1:
DEVMODE devmode;
memset(&devmode, 0, sizeof (devmode));
devmode.dmSize = sizeof(DEVMODE);
devmode.dmDriverExtra = 0;
BOOL Isgetdisplay = EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode);
使用示例2:
DEVMODE dm;
dm.dmSize = sizeof(DEVMODE);
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
int dmLogPixels = dm.dmLogPixels;
qreal dpi = dmLogPixels;
qreal dpiRatio = 1.0; // 设备像素比
if (dpi <= 108) { // 0-96-108
dpiRatio = 1.0;
}
else if (dpi <= 132) { // 108-120-132
dpiRatio = 1.25;
}
else if (dpi <= 168) { // 132-144-168
dpiRatio = 1.5;
}
else { // 168-192-inf
dpiRatio = 2.0;
}