Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, ByVal iModeNum As Long, lpDevMode As DEVMODE) As Long
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.
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).
None.
Const ENUM_CURRENT_SETTINGS = -1 Const ENUM_REGISTRY_SETTINGS = -2
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
ChangeDisplaySettings
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