windows程序设计 获取显示器分辨率

时间:2024-07-21 10:33:50

我的显示器分辨率windows程序设计 获取显示器分辨率

/*---------------------------------------------------------------------------

    scrsize.c -- 显示屏幕大小

----------------------------------------------------------------------------*/

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
TCHAR str[1024];
int cxScreen, cyScreen;
cxScreen = GetSystemMetrics(SM_CXSCREEN);//获取显示器屏幕宽度像素值
cyScreen = GetSystemMetrics(SM_CYSCREEN);//获取显示器屏幕高度像素值
wsprintf(str, TEXT("cxScreen=%d cyScreen=%d"), cxScreen, cyScreen);//将屏幕宽度和高度值输入到str字符串中 MessageBox(NULL, str, TEXT("cabbage message"), MB_OK);
return 0;
}

  

运行结果

windows程序设计 获取显示器分辨率