Use Windows API to get and change the current display settings

Source: Internet
Author: User

# Include <windows. h>
# Include <stdio. h>
# Include <conio. h>

Void main ()
{
Devmode, oldmode;
Enumdisplaysettings (null, enum_current_settings, & devmode );
Zeromemory (& oldmode, sizeof (devmode ));
Copymemory (& oldmode, & devmode, sizeof (devmode ));
Printf ("bitsperpel: % d \ n", devmode. dmbitsperpel );
Printf ("displayfrequency: % d \ n", devmode. dmdisplayfrequency );
Printf ("pelswidth: % d \ n", devmode. dmpelswidth );
Printf ("pelsheight: % d \ n", devmode. dmpelsheight );
Printf ("press any key to change display... \ n ");
Getch ();
Printf ("bitsperpel: % d \ n", devmode. dmbitsperpel = 16 );
Printf ("displayfrequency: % d \ n", devmode. dmdisplayfrequency = 60 );
Printf ("pelswidth: % d \ n", devmode. dmpelswidth = 800 );
Printf ("pelsheight: % d \ n", devmode. dmpelsheight = 600 );
Changedisplaysettings (& devmode, 0 );
Printf ("press any key to restore... \ n ");
Getch ();
Printf ("bitsperpel: % d \ n", oldmode. dmbitsperpel );
Printf ("displayfrequency: % d \ n", oldmode. dmdisplayfrequency );
Printf ("pelswidth: % d \ n", oldmode. dmpelswidth );
Printf ("pelsheight: % d \ n", oldmode. dmpelsheight );
Printf ("press any key to change display... \ n ");
Changedisplaysettings (& oldmode, 0 );
Getch ();
}

Related Article

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.