1

I want to code (in C#) a tool to add/modify/delete some of the available Windows display configurations (width, height and refresh rate).

Can this be done programmatically? I've spent many hours trying to find something about this online but had no luck.

The reason i want it is because of some older full screen games that keep setting the refresh rate back to 60hz from whatever it were when the game started (120hz in my case). I can solve that problem using Alt-Tab twice but I rather want to just limit the available display configurations (or change the refresh rate for some of them) instead.

Before considering all this I've tried to solve my problem with these attempts:

  1. Intercepting the keyboard (using this class Global keyboard capture in C# application) and then attempt a force display change when a hotkey it pressed. It works fine for just about all normal apps. But when a full screen game is running the keydown event doesn't fire. Either it is not possible when a full screen game has focus or I don't just know how to do it properly (very likely as I am a newbie in that regards).

  2. Tried using a timer to periodically check for a certain resolution and if 60hz is detected then try to set it to 120hz. The timer does fire and the code tries to change the monitor (which flickers briefly) - but the refresh rate doesn't change.

Another idea I had was to use Mhook or Detours to intercept the 'change display setting'-call. But I don't know if that'll work. And I also have no experience with C++. So I really don't want to go that way if I can avoid it.

yekanchi
  • 813
  • 1
  • 12
  • 30
Mick
  • 11
  • 3

1 Answers1

0

Can this be programmatically? I've spent many hours trying to find something about this online but had no luck.

This settings are not part of the standard .Net Framework but there is interface to manipulate these settings for windows problematically using win32 APIs. you can look here on how to call windows APIs using .Net Framework. then you can call a windows API to change the resolution for instance.

yekanchi
  • 813
  • 1
  • 12
  • 30
  • I already have all the display get/set methods working (using Win32 imports in a C# wrapper). But the don't work when a full screen game is active. Please re-read the question :) – Mick Apr 14 '19 at 16:25