void CEasySizeDlg::OnBnClickedButton1()
{
//m_nBitsPerPixel = 32;//像素位数
//m_nWidthPixels = 1024;//屏幕像素
//m_nHeightPixels = 768;
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 = ChangeDisplaySettings(&lpDevMode,0);
if(result == DISP_CHANGE_SUCCESSFUL)
{
AfxMessageBox(_T(“修改成功”));
ChangeDisplaySettings(&lpDevMode,CDS_UPDATEREGISTRY);
//使用CDS_UPDATEREGISTRY表示次修改是持久的,
//并在注册表中写入了相关的数据
}else{
AfxMessageBox(_T(“修改失败,恢复原有设置”));
ChangeDisplaySettings(NULL,0);
}
}