//检测当前分辨率
int Width = GetSystemMetrics(SM_CXSCREEN);
int Height = GetSystemMetrics(SM_CYSCREEN);
DEVMODE lpDevMode0;
lpDevMode0.dmBitsPerPel=;
lpDevMode0.dmPelsWidth=Width;
lpDevMode0.dmPelsHeight=Height;
lpDevMode0.dmSize=sizeof(lpDevMode0);
lpDevMode0.dmFields =DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL;
//修改
DEVMODE lpDevMode;
lpDevMode.dmBitsPerPel=;
lpDevMode.dmPelsWidth=;
lpDevMode.dmPelsHeight=;
lpDevMode.dmSize=sizeof(lpDevMode);
lpDevMode.dmFields =DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL;
LONG result;
result=ChangeDisplaySettings(&lpDevMode,);
if (result==DISP_CHANGE_SUCCESSFUL)
{
//MessageBox("修改成功!");
ChangeDisplaySettings(&lpDevMode,CDS_UPDATEREGISTRY);
// //使用CDS_UPDATEREGISTRY表示次修改是持久的,
// //并在注册表中写入了相关的数据
MessageBox("修改成功!还原");
if(IDOK)
{
ChangeDisplaySettings(&lpDevMode0,CDS_UPDATEREGISTRY);
}
}
else
{
//MessageBox("修改失败,恢复原有设置!");
ChangeDisplaySettings(NULL,);
}
出处:http://blog.csdn.net/nat_myron/article/details/8502009