如何在C ++中获得屏幕分辨率?

可能重复:
如何从hWnd获得显示器屏幕分辨率

有没有办法获得在C + +的屏幕分辨率?
我search了MSDN,但没有运气。 我发现最接近的是ChangeDisplaySettingsEx(),但似乎没有办法只是返回res而不改变它。

Solutions Collecting From Web of "如何在C ++中获得屏幕分辨率?"

 #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 ++ builder中,你可以像这样得到它

 Screen->Height; Screen->Width; 

这是专门为VCL框架提供与Embarcadero产品:C + + Builder,德尔福。