tags:

views:

163

answers:

3

Hi,

I'm a C# developer and I have to change my display resolution regularly.

There are plenty of examples on how to read the current display resolutions: SystemInformation.PrimaryMonitorSize

I found the ChangeDisplaySettingsEx Function

Is the only way to do this in C# is with PInvoke???

It seems odd to me that it is very easy to get this information out, but difficult to set it...

+1  A: 

You'll have to make a PInvoke call to ChangedisplaySetting.

Here's a link that has some sample code, http://www.xtremedotnettalk.com/printthread.php?t=73184.

Joshua Belden
+1  A: 

I also recommend that you check out Jared Parsons PInvoke Toolkit. You can download it here:

http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120

It makes adding pinvoke signatures to your code a breeze. It doesn't always pick the right interop types, but it's usually pretty close, and even if you have to make some changes its still usually quicker than translating everything by hand.

Scott Wisniewski
A: 

Simple answer: Yes. You should use PInvoke.

M. Jahedbozorgan
Should use? Or is that the only option?
Christian Payne