//获取分辨率
int m_nWindwMetricsX = ::GetSystemMetrics(SM_CXSCREEN);
int m_nWindwMetricsY = ::GetSystemMetrics(SM_CYSCREEN);
//修改分辨率
DEVMODE lpDevMode;
lpDevMode.dmBitsPerPel=32;
lpDevMode.dmPelsWidth=1024;
lpDevMode.dmPelsHeight=768;
lpDevMode.dmSize=sizeof(lpDevMode);
lpDevMode.dmFields =DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL;
LONG result;
result=ChangeDisplaySettings(&lpDevMode,0);
if (result==DISP_CHANGE_SUCCESSFUL)
{
AfxMessageBox(L"修改成功!");
ChangeDisplaySettings(&lpDevMode,CDS_UPDATEREGISTRY);
// //使用CDS_UPDATEREGISTRY表示次修改是持久的,
// //并在注册表中写入了相关的数据
}
else
{
AfxMessageBox(L"修改失败,恢复原有设置!");
ChangeDisplaySettings(NULL,0);
}