Solved

Access the Display Properties Panel in Windows

Posted on 2006-11-08
5
387 Views
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??
Cuchulan
0
Comment
Question by:Cuchulan
  • 3
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
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?


import java.io.IOException;

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

Author Comment

by:Cuchulan
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.

Cheers!
0
 
LVL 6

Expert Comment

by:superm401
ID: 17996867
I found some API documentation (http://msdn2.microsoft.com/en-gb/library/ms533235.aspx) 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.
0
 

Author Comment

by:Cuchulan
ID: 17997588
Will try that out.

Thanks for all your help superm401!

Cheers!

0
 
LVL 6

Expert Comment

by:superm401
ID: 18015813
You're welcome.  Best of luck.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

730 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