关闭

利用windows API更改显示器的分辨率和更改双屏的显示模式

1329人阅读 评论(0) 收藏 举报

//更改显示屏的分辨率(windows8)
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));  
dmScreenSettings.dmSize = sizeof(dmScreenSettings); 
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dmScreenSettings); 
dmScreenSettings.dmPelsWidth = 1024; 
dmScreenSettings.dmPelsHeight = 768; 
ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN);
system("pause");


//上述方法在windows7上不太适用,针对以上做以下更改

//设置屏幕的分辨率
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));  
dmScreenSettings.dmSize = sizeof(dmScreenSettings); 
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL;
dmScreenSettings.dmPelsWidth = 1440; 
dmScreenSettings.dmPelsHeight = 900;  
long result = ChangeDisplaySettings(&dmScreenSettings,0);
if (result == DISP_CHANGE_SUCCESSFUL)
{
MessageBox(NULL,TEXT("分辨率修改成功!"),TEXT("提示"),MB_ICONEXCLAMATION|MB_OK);
ChangeDisplaySettings(&dmScreenSettings,CDS_UPDATEREGISTRY);
}
else
{
MessageBox(NULL,TEXT("分辨率修改失败"),TEXT("提示"),MB_ICONEXCLAMATION|MB_OK);
ChangeDisplaySettings(NULL,0);
}


//更改屏幕多屏幕的显示模式 
system ("DisplaySwitch.exe /clone");  //屏幕复制
system ("DisplaySwitch.exe /extend"); //屏幕扩展
system ("DisplaySwitch.exe /internal");//仅电脑屏幕
system ("DisplaySwitch.exe /external"); //仅第二屏幕




0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:6187次
    • 积分:175
    • 等级:
    • 排名:千里之外
    • 原创:14篇
    • 转载:7篇
    • 译文:0篇
    • 评论:0条