hi today I’m going to demonstrate how to write a simple win32 program using C++
to display screen resolution values using a simple Message Box.
Here is the source code.
#include <windows.h>
#include <tchar.h>
TCHARÂ gResultOutBuffer [80];
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int iCmdShow)
{
// get the vertical resolution.
int vert_res = GetSystemMetrics(SM_CYSCREEN);
// get the horizontal resolution.
int hori_res = GetSystemMetrics(SM_CXSCREEN);
// then create use wsprintf to print it to an
// appropriate buffer.
wsprintf(gResultOutBuffer,_T("Resolution is : %dx%d \n" ),hori_res,vert_res );
// Then Create a MessageBox and show it to the user.
MessageBox(NULL,gResultOutBuffer,_T("screen resolution"),MB_OK);
return 0;
}
And here is how you should compile this,

and for more information head to the http://msdn.microsoft.com/en-us/library/ms724385%28VS.85%29.aspx
–Happy Coding–
Advertisement