Consider this piece of code:
Code:
#include<windows.h>
#include<stdio.h>
#include<conio.h>
DWORD w[] = {640,800,1024,1280};
DWORD h[] = {480,600, 768,1024};
int main(){
DEVMODE d;
int i;
ZeroMemory(&d, sizeof(DEVMODE));
d.dmSize = sizeof(DEVMODE);
d.dmDisplayFlags = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS;
for(i=0;i<4;i++){
printf("mode: %d x %d -> ",w[i],h[i]);
d.dmPelsHeight = h[i];
d.dmPelsWidth = w[i];
switch(ChangeDisplaySettings(&d,0)){
case DISP_CHANGE_SUCCESSFUL:
puts("SUCCESS");break;
case DISP_CHANGE_RESTART:
puts("RESTART");break;
case DISP_CHANGE_BADFLAGS:
puts("BADFLAGS");break;
case DISP_CHANGE_FAILED:
puts("FAILED");break;
case DISP_CHANGE_BADMODE:
puts("BADMODE");break;
case DISP_CHANGE_NOTUPDATED:
puts("NOTUPDATED");break;
default:
puts("ERROR");break;
}
getch();
}
}
My current desktop resolution is 1280x1024. I can't change to a lower one. If change the resolution in my monitor properties, and then run the program, when the resolution should change to 800x600, it changes to 1280x1024 directly.
But worst of all, the ChangeDisplaySetting function always returns DISP_CHANGE_SUCCESSFUL.
1# What's wrong with this??
2# Is there another good way to change my desktop resolution??