如何在C++中获取屏幕分辨率
How to get screen resolution in C++?
可能的重复项:
如何从hWnd获取显示器屏幕分辨率?
有没有办法获得C++的屏幕分辨率?
我已经搜索了MSDN,但没有运气。我发现的最接近的东西是 ChangeDisplaySettingsEx((,但这似乎没有办法只返回 res 而不更改它。
#include "wtypes.h"
#include <iostream>
using namespace std;
// Get the horizontal and vertical screen sizes in pixel
void GetDesktopResolution(int& horizontal, int& vertical)
{
RECT desktop;
// Get a handle to the desktop window
const HWND hDesktop = GetDesktopWindow();
// Get the size of screen to the variable desktop
GetWindowRect(hDesktop, &desktop);
// The top left corner will have coordinates (0,0)
// and the bottom right corner will have coordinates
// (horizontal, vertical)
horizontal = desktop.right;
vertical = desktop.bottom;
}
int main()
{
int horizontal = 0;
int vertical = 0;
GetDesktopResolution(horizontal, vertical);
cout << horizontal << 'n' << vertical << 'n';
return 0;
}
来源: http://cppkid.wordpress.com/2009/01/07/how-to-get-the-screen-resolution-in-pixels/
在Embarcadero C++构建器中,你可以这样得到它
Screen->Height;
Screen->Width;
这是特定于Embarcadero产品提供的VCL框架:C++ Builder,Delphi。
相关文章:
- 获取网格中心的屏幕位置
- 获取可能的屏幕分辨率列表
- 如何使用 c++ mfc 在屏幕上获取鼠标事件
- 如何从保存的几何体中获取屏幕编号?
- 从交换链获取多个屏幕缓冲区
- MFC和Windows API之间的区别在获取屏幕分辨率方面
- 在Qt中获取屏幕对角线大小
- 使用二维屏幕坐标gluUnproject获取三维模型坐标
- GLFW 获取屏幕高度/宽度
- 在窗口中的屏幕上获取坐标像素数据的简单方法
- SDL_MapRGB,如何使用指针到指针获取屏幕>格式
- 使用C++获取Linux机器的屏幕截图
- QML地图:点击屏幕时获取坐标
- 如何使用DX9获取其他全屏游戏的屏幕截图
- 如何在 x11 中获取屏幕像素的颜色
- 如何在SDL中获取屏幕大小
- 如何在C++中获取屏幕分辨率
- 获取所有支持的屏幕分辨率
- 获取屏幕宽度和屏幕高度
- GetDC(NULL)获取主监视器或虚拟屏幕