I'm creating an application that runs a game multiple times to play split screen with your friends. When using the new, yet to be released, console mode in my application, you first have to manually set two custom resolutions in control panel. Does anyone know of a way that I could set these resolutions via c# code before launching the game instances?
Asked
Active
Viewed 224 times
-1
-
This may be relevant: http://stackoverflow.com/questions/15099523/changing-console-windows-size-throws-argumentoutofrangeexception – NoChance Aug 15 '16 at 03:37
-
I don't believe so as I'm not changing a console window's height or width. – PlGGS Aug 15 '16 at 04:09
1 Answers
-1
In order to set the resolution, you will have to use P/Invoke. There is an example from the MSDN library here (scroll to Task 2). Another example can be found here, which uses the same approach.

Bastian Thiede
- 458
- 2
- 8
-
While I can see how this could be helpful, it's sadly not what I'm looking for. Windows comes with some preset resolutions for the computer to use when rendering screens and windows. You can add to these resolutions in the Nvidia and AMD control panels. Only after adding a new resolution to one of these lists, will your computer be able to run games such as Halo: Online at these resolutions. Right now I can't find a way to add a resolution to one of these lists without manually opening up one of the control panels and setting them manually. I'm not looking to set the screen resolution. – PlGGS Aug 16 '16 at 06:06
-
Okay, thanks for clarification, @PlGGS. Unfortunately, I don't know about any Windows built-in way to achive this. I think you would have to use the vendor specific API in this case. However, since the graphics engine shouldn't have any problems to render at any (not predefined) resolution, maybe there is a config file with resolution settings? Can you edit the values and test what happens? Your split screen app could edit all the config files before starting the game. – Bastian Thiede Aug 16 '16 at 07:40
-
I see, @Bastian . The app already defines the resolution the user chooses from a list of resolutions defined on the PC you're using. Before I implemented this feature people would do it manually like [this](https://www.reddit.com/r/HaloOnline/comments/4qi0qm/halo_online_split_screen_done_right/d4tbgz0). If you set the game to run at a resolution that your PC doesn't have listed, it runs it in the one that is closest to it on the list. That's why the person in the thread above had to jimmy rig a new resolution into the list to get it to run at it – PlGGS Aug 17 '16 at 20:49