获取当前显示屏分辨率

就是显示控制台窗口的那个显示屏的分辨率

#include <Windows.h>
#include <stdio.h>

int main()
{
    int nScreenWidth, nScreenHeight;
    nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
    nScreenHeight = GetSystemMetrics(SM_CYSCREEN);

    printf("当前屏幕的分辨率为:%d×%d", nScreenWidth, nScreenHeight);

    getchar();
    return 0;
}

运行结果:

当前屏幕的分辨率为:1920×1080

获取显示屏个数

我现在的电脑接了4个显示屏。

#include <Windows.h>
#include <stdio.h>

int main()
{
    int screenNum;
    screenNum = GetSystemMetrics(SM_CMONITORS);
    printf("当前屏幕数量:%d\n", screenNum);

    getchar();
    return 0;
}

运行输出:

当前屏幕数量:4

获取屏幕的总分辨率

#include <Windows.h>
#include <stdio.h>

int main()
{
    int aScreenWidth, aScreenHeight;
    aScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
    aScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);

    printf("当前屏幕总的分辨率为:%d×%d \n", aScreenWidth, aScreenHeight);

    getchar();
    return 0;
}

运行输出:

当前屏幕总的分辨率为:6400×1080

获取各个屏幕的分辨率

待续


参考网站:
http://www.it610.com/article/1468754.htm
http://my.oschina.net/u/1255773/blog/177533
http://blog.csdn.net/hzy694358/article/details/7396130