возможные дубликаты: как сделать разрешение экрана монитора от hWnd?
в
Есть ли способ сделать разрешение экрана в C++? Я искал в MSDN, но не повезло. Самое близкое, что я нашел ChangeDisplaySettingsEx() но это не'т, кажется, есть способ, чтобы просто вернуть РЭС без изменения.
#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 с++ Builder вы можете сделать ее такой
Screen->Height;
Screen->Width;
Это является специфическим для базы VCL, которые поставляются продукты Embarcadero: C++ и билдер, Делфи.