Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Download Visual Studio Add-In

EnumDisplaySettings (user32)
The EnumDisplaySettings API enumerates the display settings for the machine (surprise!). It returns a DEVMODE struct which contains the current settings. Use ChangeDisplaySettings to change those values.

C# Signature:

public static extern bool EnumDisplaySettings (string deviceName, int modeNum, ref DEVMODE devMode );  
static extern bool EnumDisplaySettingsEx(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode, uint dwFlags);

VB.NET Signature:

<DllImport("user32")> _
Public Function EnumDisplaySettings(ByVal deviceName As String, ByVal modeNum As Integer, ByRef devMode As DEVMODE) As Boolean
<DllImport("user32.dll")> _
Private Shared Function EnumDisplaySettingsEx(ByVal lpszDeviceName As String, ByVal iModeNum As UInteger, ByRef lpDevMode As DEVMODE, ByVal dwFlags As UInteger) As Boolean
End Function

User-Defined Types:




See also: EnumDisplaySettings

See also: EnumDisplaySettingsEx

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!

using System.Runtime.InteropServices;
public struct DEVMODE
    private const int CCHDEVICENAME = 0x20;
    private const int CCHFORMNAME = 0x20;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
    public string dmDeviceName;
    public short dmSpecVersion;
    public short dmDriverVersion;
    public short dmSize;
    public short dmDriverExtra;
    public int dmFields;
    public int dmPositionX;
    public int dmPositionY;
    public ScreenOrientation dmDisplayOrientation;
    public int dmDisplayFixedOutput;
    public short dmColor;
    public short dmDuplex;
    public short dmYResolution;
    public short dmTTOption;
    public short dmCollate;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
    public string dmFormName;
    public short dmLogPixels;
    public int dmBitsPerPel;
    public int dmPelsWidth;
    public int dmPelsHeight;
    public int dmDisplayFlags;
    public int dmDisplayFrequency;
    public int dmICMMethod;
    public int dmICMIntent;
    public int dmMediaType;
    public int dmDitherType;
    public int dmReserved1;
    public int dmReserved2;
    public int dmPanningWidth;
    public int dmPanningHeight;


public static extern bool EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode);

private void button1_Click(object sender, EventArgs e)
    DEVMODE vDevMode = new DEVMODE();
    int i = 0;
    while (EnumDisplaySettings(null, i, ref vDevMode))
    Console.WriteLine("Width:{0} Height:{1} Color:{2} Frequency:{3}",
1 << vDevMode.dmBitsPerPel,         vDevMode.dmDisplayFrequency

With reference to the "Documentation EnumDisplaySettingsEx on MSDN"

There seems to be an error in the link.

Alternative Managed API:

Do you know one? Please contribute it!


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version