Programmatically change screen resolution?

27,367

Solution 1

You can use EnumDisplayDevices to figure out what displays you have available and EnumDisplaySettings to get a list of available resolutions for your displays. Use ChangeDisplaySettings to set the resolution you need.

Solution 2

Yes, but its not part of .NET. You will need to use, invoke or write a wrapper to access the Win32 API.

See ChangeDisplaySettings and related function.

Here you can find a basic example.

Share:
27,367
jacobsee
Author by

jacobsee

Working in C++ on an industrial data acquisition application.

Updated on October 25, 2021

Comments

  • jacobsee
    jacobsee over 2 years

    Is there a way to programmatically change the screen resolution or enable/disable multiple monitors in Windows XP? For example to change from 1024x768 with one monitor to 1280x1024 on two monitors? I would be most interested in a win32 function to do this but anything that can be tied to a windows shortcut would suffice.

  • Thomas Foster
    Thomas Foster almost 8 years
    The question wasn't about .NET.
  • Bill
    Bill over 4 years
    I found a great working implementation of these APIs using C#. Easy to create a shortcut for it. If you don't want to run a program after changing the resolution, simply remove the few lines of code that the author included to start a program. In my case, I use it to lower my 4k screen resolution down to 1920x1080 before sharing my screen on WebEx. After I'm done, I have a different shortcut to reset back to max resolution.