
Unfortunately, EnumDisplaySettings() can return only one mode per call, and that mode is encapsulated into the DEVMODE object. The DEVMODE's dmSize member is used for input to represent the structure size, while other members are used for output.Īs you might expect, to retrieve the current mode (settings) of the current display device, you will need to pass a NULL value as the lpszDeviceName parameter to indicate the current display, and the value -1 to the iModeNum parameter to indicate the current mode.
lpDevMode: A reference (In/Out) parameter representing the DEVMODE object that encapsulates the retrieved display mode information. ENUM_REGISTRY_SETTINGS = -2: Retrieves the current display mode stored in the Registry. ENUM_CURRENT_SETTINGS = -1: Retrieves the current display mode. It could be either a mode index or one of these values: iModeNum: Specifies the type of information to retrieve.
You can enumerate display devices using the EnumDisplayDevices() function. This parameter can be either NULL to indicate the default device, or the name of the display device.
lpszDeviceName: Specifies the display device name that will be used to retrieve its modes. This function accepts only three parameters: LPDEVMODE lpDevMode // graphics mode settings LPCTSTR lpszDeviceName, // display device The definition of this function is as follows: It is used to retrieve one of the modes supported by a graphics device. After that, we will focus on the implementation code. Now, we are going to discuss the required functions and structures and how to use them. This article also comes with a sample application used for changing the display settings. Along with the discussion, you will learn additional techniques like how to PInvoke Win32 API functions and to marshal unmanaged data types. As you already know, a mode is a combination of many display settings including bounds, bit count, orientation, and frequency therefore, we will refer to display settings as display modes.įinally, this article discusses how to change the current display settings. After that, it discusses how to get all the modes supported by your display. Then, it focuses on how to retrieve the current display settings. This article firstly discusses the required functions and structures.
Changing the Screen Resolution and Bit Count. Enumerating the Supported Display Modes. We will change the screen resolution (bounds,) color system (bit count), rotation (orientation), and refresh rate (frequency) via an API with C# and the. Today, we are talking about how to change display settings via an API.