VC obtains the resolution and refresh frequency of the display.

Source: Internet
Author: User

 

# Include "stdafx. H"
Int apientry winmain (hinstance,
Hinstance hprevinstance,
Lpstr lpcmdline,
Int ncmdshow)
{
// Todo: Place code here.

Char current [100];
Devmode DM;
DM. dmsize = sizeof (devmode );
: Enumdisplaysettings (null, enum_current_settings, & DM );

 
Wsprintf (current, "% s at % DX % d % dbpp % DHZ ",

DM. dmdevicename,
DM. dmpelswidth,
DM. dmpelsheight,
DM. dmbitsperpel,
DM. dmdisplayfrequency );

MessageBox (null, current, "display information", mb_ OK );

Return 0;
}

Create a Win32 program in VC. The complete program is as above.

 

The enumdisplaysettings function in Baidu encyclopedia is described as follows:

Function: This function is used to obtain a graphical mode device of the display device. You can call this function to obtain all the graphical mode information of the display device.

Function prototype: bool enumdisplaysettings (lpctstr lpszdevicename, DWORD imodenum, lpdevmode );

Parameters:

Lpszdevicename: point to a null string that specifies the display device. This function obtains the graphical mode information of the display device. This parameter can be null. Null indicates that the call thread is running on the current display device of the computer. If lpszdevicename is null, the string format is \. \ displayx. The value of X can be 1, 2, or 3. For Windows 95 and Windows 98, the lpszdevicename must be null.

Imodenum: indicates the type of information to be retrieved. The value can be a graphical index or the following:

Enum_current_settings: retrieves the current settings of the display device.

Enum_registry_settings: retrieves the settings of the display device currently stored in the registry.

The image mode index value starts from scratch. To obtain information about all the image modes of a display device, you can call the enumdisplaysettings function in a series, and when imodenum is a non-zero value, the information returned by the function is the information stored when the last time imodenum is set to zero to call the function.

Lpdevmode: pointer to the devmode structure, which stores information about the specified graphic mode. Before calling enumdisplaysettings, set dmsize to sizeof (devmode), in bytes, set the dmdriveextra element to an additional space available for receiving data from a dedicated driver.

The enumdisplaysettings function sets the values of the following five devmode elements: dmbitsperpel, dmpelswidth, dmpelsheight, dmdisplayflags, and dmdisplayfrequency.

Return Value: if the operation succeeds, a non-zero value is returned. If the operation fails, zero is returned.

Windows NT: To obtain more error information, call the getlasterror function.

NOTE: If imodenum is greater than the display device's final graph mode index, the function will fail, as described in the imodenum parameter, this method can be used to enumerate all the image modes of the display device.

Quick query: Windows NT: 3.51 or later; windows: 95 or later; Windows CE: not supported; header file: winuser. h; library file: user32.lib; UNICODE: Unicode and ANSI are implemented on Windows NT.

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.