Get the number and resolution of the display

Source: Internet
Author: User
get current display resolution

Is the resolution of the screen that displays the console window.

#include <Windows.h>
#include <stdio.h>

int main ()
{
    int nscreenwidth, nscreenheight;
    Nscreenwidth = GetSystemMetrics (sm_cxscreen);
    Nscreenheight = GetSystemMetrics (sm_cyscreen);

    printf ("The current screen resolution is:%dx%d", Nscreenwidth, nscreenheight);

    GetChar ();
    return 0;
}

Run Result:

The resolution of the current screen is: 1920x1080
get the number of screens

My Computer now has 4 screens.

#include <Windows.h>
#include <stdio.h>

int main ()
{
    int screennum;
    Screennum = GetSystemMetrics (sm_cmonitors);
    printf ("Current number of screens:%d\n", screennum);

    GetChar ();
    return 0;
}

Run the output:

Current screen Number: 4
get the total resolution of the screen
#include <Windows.h>
#include <stdio.h>

int main ()
{
    int ascreenwidth, ascreenheight;
    Ascreenwidth = GetSystemMetrics (sm_cxvirtualscreen);
    Ascreenheight = GetSystemMetrics (sm_cyvirtualscreen);

    printf ("The current screen total resolution is:%dx%d \ n", Ascreenwidth, ascreenheight);

    GetChar ();
    return 0;
}

Run the output:

The total resolution for the current screen is: 6400x1080
get the resolution of each screen

-To be continued

Reference website:
Http://www.it610.com/article/1468754.htm
http://my.oschina.net/u/1255773/blog/177533
http://blog.csdn.net/hzy694358/article/details/7396130

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.