打印屏幕大小

2019-04-27  本文已影响0人  louyang

在VS2019中新建一个空白项目:

image.png

在Source Files目录下添加一个cpp文件。

image.png

文件内容:

#include <windows.h>
#include <wchar.h>

#pragma comment(lib, "user32.lib")

int wmain(void) {

    int x = GetSystemMetrics(SM_CXSCREEN);
    int y = GetSystemMetrics(SM_CYSCREEN);

    wprintf(L"The screen size is: %dx%d\n", x, y);

    return 0;
}

按F5编译运行,可以看到:

The screen size is: 1920x1080
参考

http://zetcode.com/gui/winapi/system/

上一篇 下一篇

猜你喜欢

热点阅读