HDC hScrDC;
// 屏幕和内存设备描述表
int xScrn, yScrn;
// 屏幕分辨率
//为屏幕创建设备描述表
hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
// 获得当前屏幕分辨率
xScrn = GetDeviceCaps(hScrDC, HORZRES);
yScrn = GetDeviceCaps(hScrDC, VERTRES);
DeleteDC(hScrDC);
CString str;
str.Format("X=%d\n Y=%d",xScrn,yScrn);
MessageBox(str,"当前屏幕分辨率",MB_OK);
//设置分辨率
DEVMODE DevMode;
DevMode.dmBitsPerPel=16;
DevMode.dmPelsWidth=800 ; //水平分辨率
DevMode.dmPelsHeight=600; //垂直分辨率
DevMode.dmDisplayFrequency=85;
DevMode.dmSize=sizeof(DevMode);
DevMode.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL|DM_DISPLAYFREQUENCY;
long result;
result=ChangeDisplaySettingsEx(NULL,&DevMode,NULL,0,NULL);
CString str1;
str1.Format("X=%d\n Y=%d",DevMode.dmPelsWidth,DevMode.dmPelsHeight);
MessageBox(str1,"当前屏幕分辨率",MB_OK);
// 屏幕和内存设备描述表
int xScrn, yScrn;
// 屏幕分辨率
//为屏幕创建设备描述表
hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
// 获得当前屏幕分辨率
xScrn = GetDeviceCaps(hScrDC, HORZRES);
yScrn = GetDeviceCaps(hScrDC, VERTRES);
DeleteDC(hScrDC);
CString str;
str.Format("X=%d\n Y=%d",xScrn,yScrn);
MessageBox(str,"当前屏幕分辨率",MB_OK);
//设置分辨率
DEVMODE DevMode;
DevMode.dmBitsPerPel=16;
DevMode.dmPelsWidth=800 ; //水平分辨率
DevMode.dmPelsHeight=600; //垂直分辨率
DevMode.dmDisplayFrequency=85;
DevMode.dmSize=sizeof(DevMode);
DevMode.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL|DM_DISPLAYFREQUENCY;
long result;
result=ChangeDisplaySettingsEx(NULL,&DevMode,NULL,0,NULL);
CString str1;
str1.Format("X=%d\n Y=%d",DevMode.dmPelsWidth,DevMode.dmPelsHeight);
MessageBox(str1,"当前屏幕分辨率",MB_OK);