EnumDisplaySettings Function

Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, ByVal iModeNum As Long, lpDevMode As DEVMODE) As Long

Platforms

Description & Usage

EnumDisplaySettings gets the display settings of one of a display device's graphics modes. Specifically, the function gets the display mode's resolution, color depth, and frequency, along with some additional information.

Return Value

If successful, the function returns a non-zero value. If an error occured, the function returns zero (Windows NT/2000: use GetLastError to get the error code).

Visual Basic-Specific Issues

None.

Parameters

lpszDeviceName
Windows 95, 98: This must be a null string. Windows NT, 2000: If this is a null string, the current display device is used. Otherwise, this is the device name of the display device to examine. The string is of the form "\\.\DisplayX", where X is 1, 2, or 3.
iModeNum
The number of the graphics mode to retrieve information about. This could also be one of the following flags specifying a graphics mode:
ENUM_CURRENT_SETTINGS
Get information about the current display settings.
ENUM_REGISTRY_SETTINGS
Get information about the display settings stored in the registry.
lpDevMode
Receives information about the graphics mode. Only the dmBitsPerPixel, dmPelsWidth, dmPelsHeight, dmDisplayFlags, and dmDisplayFrequency members have useful data in them. Before calling the function, this structure's dmSize member must be properly set.

Constant Definitions

Const ENUM_CURRENT_SETTINGS = -1
Const ENUM_REGISTRY_SETTINGS = -2

Example

Display information about the current display settings for the monitor. To use this example, place a command button named Command1 on a form window.

' This code is licensed according to the terms and conditions listed here.

' Declarations and such needed for the example:
' (Copy them to the (declarations) section of a module.)
Public Type DEVMODE
	dmDeviceName As String * 32
	dmSpecVersion As Integer
	dmDriverVersion As Integer
	dmSize As Integer
	dmDriverExtra As Integer
	dmFields As Long
	dmOrientation As Integer
	dmPaperSize As Integer
	dmPaperLength As Integer
	dmPaperWidth As Integer
	dmScale As Integer
	dmCopies As Integer
	dmDefaultSource As Integer
	dmPrintQuality As Integer
	dmColor As Integer
	dmDuplex As Integer
	dmYResolution As Integer
	dmTTOption As Integer
	dmCollate As Integer
	dmFormName As String * 32
	dmUnusedPadding As Integer
	dmBitsPerPixel As Integer
	dmPelsWidth As Long
	dmPelsHeight As Long
	dmDisplayFlags As Long
	dmDisplayFrequency As Long
	' The following only appear in Windows 95, 98, 2000
	dmICMMethod As Long
	dmICMIntent As Long
	dmMediaType As Long
	dmDitherType As Long
	dmReserved1 As Long
	dmReserved2 As Long
	' The following only appear in Windows 2000
	dmPanningWidth As Long
	dmPanningHeight As Long
End Type
Public Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, _
	ByVal iModeNum As Long, lpDevMode As DEVMODE) As Long
Public Const ENUM_CURRENT_SETTINGS = -1
Public Const ENUM_REGISTRY_SETTINGS = -2

' *** Place the following code inside the form window. ***

Private Sub Command1_Click()
	Dim dm As DEVMODE   ' info about the display device
	Dim retval As Long  ' return value
	
	' Initialize the structure.
	dm.dmSize = Len(dm)
	' Get the display settings for the current monitor and mode.
	retval = EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dm)
	' Print some information about the display.
	Debug.Print "- Bits Per Pixel: "; dm.dmBitsPerPixel
	Debug.Print "- Width (Pixels): "; dm.dmPelsWidth
	Debug.Print "- Height (Pixels):"; dm.dmPelsHeight
	Debug.Print "- Display Freq.:  "; dm.dmDisplayFrequency
End Sub

See Also

ChangeDisplaySettings

Category

Devices

Back to the Function list.
Back to the Reference section.


Last Modified: January 21, 2001
This page is copyright © 2001 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/e/enumdisplaysettings.html