From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Changing Screen Resolution Programmatically From LabVIEW

Code and Documents

Attachment

This VI calls a Visual Basic DLL in order to change the screen resolution. The DLL makes calls to the Windows API functions: "EnumDisplaySettings" and "ChangeDisplaySettings".

Before running the VI, you will have to extract the resolution.dll into a directory and register it. To register the dll, you can use regsvr32.exe as follows:

- Go to Start » Run.

- Type the following in the dialog box that appears:

regsvr32 "Full path of .dll file"

Where "Full path of .dll file" is the location of the extracted resolution.dll file.

Once the dll has been registered, run the resolution.vi. To set different resolutions, change the Resolution control in the resolution.vi. By default, it is set to 1024x768.

The "dmDisplayFrequency" parameter of the "ChangeDisplaySettings" function is not configured in the resolution.dll, so this example will reset the Screen Refresh Rate to default (60Hz). To change it manually back to the desired rate, go to
Control Panel >> Display >> Settings >> Advanced >> Monitor.
You can also change the rate programmatically by modifying the resolution.cls code.

Visual Basic source code is included for your information.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors