ChangeDisplaySettingsEx not setting resolution

时间:2015-07-28 16:24:55

标签: c++ winapi

I'm trying to programmaticly set the resolution of multiple monitors.

DISPLAY_DEVICE dd;
dd.cb = sizeof(DISPLAY_DEVICE);
DEVMODE mode;
memset(&mode, 0, sizeof(DEVMODE)); 
mode.dmSize = sizeof(DEVMODE);
mode.dmPelsWidth = width;
mode.dmPelsHeight = height; 
mode.dmDriverExtra = 0;
mode.dmDisplayFlags = DM_PELSWIDTH | DM_PELSHEIGHT;
DWORD deviceNum = 0;
while (EnumDisplayDevices(NULL, deviceNum, &dd, 0)){        
    long l = ChangeDisplaySettingsEx(dd.DeviceName, &mode, NULL, CDS_UPDATEREGISTRY | CDS_GLOBAL, NULL);
    deviceNum++;
}
ChangeDisplaySettingsEx(NULL, NULL, NULL, 0, NULL);

ChangeDisplaySettingsEx returns 0 (good value), but the monitors remain at there normal resolution.

What can I do to correct this?

0 个答案:

没有答案