獲取顯示器的數量和解析度
阿新 • • 發佈:2018-11-04
通過GetSystemMetrics 的幾個重要引數,就可以獲取顯示器的數量、當前螢幕解析度,以及總解析度:
#include "stdafx.h" #include <Windows.h> #include <stdio.h> int _tmain(int argc, _TCHAR* argv[]) { //當前螢幕的解析度 int nScreenWidth, nScreenHeight; nScreenWidth = GetSystemMetrics(SM_CXSCREEN); nScreenHeight = GetSystemMetrics(SM_CYSCREEN); printf("當前螢幕的解析度為:%d×%d", nScreenWidth, nScreenHeight); getchar(); //當前螢幕數量 int screenNum; screenNum = GetSystemMetrics(SM_CMONITORS); printf("當前螢幕數量:%d\n", screenNum); getchar(); //當前螢幕總的解析度 int aScreenWidth, aScreenHeight; aScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); aScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); printf("當前螢幕總的解析度為:%d×%d \n", aScreenWidth, aScreenHeight); getchar(); return 0; }