Access the Display Properties Panel in Windows

Posted on 2006-11-08
Last Modified: 2012-05-05
Hey Experts,

Any way to access the Display Properties panel in Windows and change settings.
Maybe I need a do this in C++/MFC's and write a JNIWrapper for this allowing me to access using Java?

I can make the Panel appear using the following command in a .bat file and forcing that to run:
Rundll32.exe shell32.dll,Control_RunDLL Desk.cpl,@0, 3

Any ideas??
Question by:Cuchulan
  • 3
  • 2

Accepted Solution

superm401 earned 300 total points
ID: 17944578
You can execute that command with the below code.  However, whether this kind of solution will suffice depends on your application.  So...what specific settings do you really need to access and/or change?


public class RuntimeHacking
      public static void main(String[] args)
            Runtime myRuntime = Runtime.getRuntime();
                  myRuntime.exec("Rundll32.exe shell32.dll,Control_RunDLL Desk.cpl,@0, 3");
            catch(IOException e)
                  System.err.println("Command execution failed.");

Author Comment

ID: 17996347
Hi superm401,

Cheers that worked for me.

The settings I need to change are to set "Use this device as the primary monitor" and "Extend my Windows Desktop onto this monitor"

If its possible for these to be changes that would be brillant.


Expert Comment

ID: 17996867
I found some API documentation ( that allows you to change the primary monitor.  I can't figure out how you would change the "extend my windows Desktop".  I think the primary monitor part could probably be handled by making a quick C application to use the API functions, then calling it with Runtime.exec, since no parameters need be passed and a JNI isn't really more elegant.

Author Comment

ID: 17997588
Will try that out.

Thanks for all your help superm401!



Expert Comment

ID: 18015813
You're welcome.  Best of luck.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 81   readLine()  //returns the entire file ? 4 60
session migration servlets 2 28
replace a word with other 1 40
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now