获取屏幕数量及宽高--GetSystemMetrics
1 #include <iostream> 2 #include <Windows.h> 3 #include "winuser.h" 4 5 6 int main() 7 { 8 // 获取桌面x坐标,可以为负值 9 int xScreen = ::GetSystemMetrics(SM_XVIRTUALSCREEN); 10 std::cout << "x坐标:" << xScreen << std::endl; 11 // 获取桌面y坐标,可以为负值 12 int yScreen = ::GetSystemMetrics(SM_YVIRTUALSCREEN); 13 std::cout << "y坐标:" << yScreen << std::endl; 14 // 获取桌面总宽度 15 int cxScreen = ::GetSystemMetrics(SM_CXVIRTUALSCREEN); 16 std::cout << "总宽度:" << cxScreen << std::endl; 17 // 获取桌面总高度 18 int cyScreen = ::GetSystemMetrics(SM_CYVIRTUALSCREEN); 19 std::cout << "高度:" << cyScreen << std::endl; 20 //获取屏幕数量 21 int nScreenCount = ::GetSystemMetrics(SM_CMONITORS); 22 std::cout << "屏幕数量:" << nScreenCount << std::endl; 23 getchar(); 24 return 0; 25 }