Solved

Access the Display Properties Panel in Windows

Posted on 2006-11-08
5
385 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

831 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