#include <windows.h>
#include <stdio.h>
void SetResolution(int width, int height)
{
DEVMODE dm;
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
if (0 != EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
{
int savew = dm.dmPelsWidth;
int saveh = dm.dmPelsHeight;
dm.dmPelsWidth = width;
dm.dmPelsHeight = height;
LONG result = ChangeDisplaySettings(&dm, 0);
if (result == DISP_CHANGE_SUCCESSFUL)
{
printf("Display change successful [%dx%d]: %d", width, height, result);
}
else
{
dm.dmPelsWidth = savew;
dm.dmPelsHeight = saveh;
ChangeDisplaySettings(&dm, 0);
printf("Display change failed [%dx%d]: %d", width, height, result);
}
}
}
void main(int argc, char** argv)
{
int w,h;
if(argc==1 || argc==2)
{
printf("Usage: cds w h\n");
}
if(argc>=3)
{
w=atoi(argv[1]);
h=atoi(argv[2]);
SetResolution(w, h);
}
}