Solved

Access the Display Properties Panel in Windows

Posted on 2006-11-08
5
383 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Will try that out.

Thanks for all your help superm401!

Cheers!

0
 
LVL 6

Expert Comment

by:superm401
Comment Utility
You're welcome.  Best of luck.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoreUp challenge 14 47
array6 challenfge 6 62
where is session ID cache stored 1 38
topping3 challenge 14 48
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…
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…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

772 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

12 Experts available now in Live!

Get 1:1 Help Now