Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (498)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to edit a windows registry key value?  (Read 3578 times)
0 Members and 1 Guest are viewing this topic.
Offline Shane75776
« Posted 2012-06-25 02:30:36 »

There is a specific key in the registry that I would like to edit with java.

The value is a String, in fact, its the 3Dtext screen savers display text.

I do not want to create a new registry key or delete one, I just want to edit one and simply change the string value
of it.


I searched all over google but all I come up with are was to create a new key.

any ideas?

Check out my Snipping Tool++ ! An advanced snippet/screenshot/text uploading tool! Meant to replace the windows snipping tool.

Check out Pixel Rain My most recent Swing based game!
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2012-06-25 02:54:42 »

Launch regedit.exe and feed it a prepared *.reg file. (tip: the comments in the file are mandatory!)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline ReBirth
« Reply #2 - Posted 2012-06-25 03:36:20 »

Assuming that you're creating a game, why you need to modify the reg?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Shane75776
« Reply #3 - Posted 2012-06-25 05:36:54 »

Assuming that you're creating a game, why you need to modify the reg?

well if you would have read my topic post, you would know that haha.

and I don't understand what you mean by feed the registry a prepared key..?

The reason I am looking to do this through code is because the key will be changing
every so often.

What I am trying to do is have a website where someone, anyone with a link can change the
text of my screen saver with a simple string input. My program, will check for a change in the
string value on the website, and if changed, change the text of my screen saver by editing my
registry.

This has nothing to do with a game and will only affect me.

Check out my Snipping Tool++ ! An advanced snippet/screenshot/text uploading tool! Meant to replace the windows snipping tool.

Check out Pixel Rain My most recent Swing based game!
Offline brionnach

Senior Newbie


Medals: 1



« Reply #4 - Posted 2012-06-25 05:56:04 »

This doesn't answer your question, but I'm wondering, have you considered using a Properties file? Is there a specific need to use the registry for this task, or is that you just want to?
Offline Shane75776
« Reply #5 - Posted 2012-06-25 06:09:56 »

This doesn't answer your question, but I'm wondering, have you considered using a Properties file? Is there a specific need to use the registry for this task, or is that you just want to?

That is how the default windows 3d text screen saver gets the text input value. through the registry, therefor I have to use the registry. Unless
I designed my own screen saver which I really dont want to do.

The closest I found to editing, is adding a new key but, that does not help me.
1  
2  
3  
4  
5  
6  
7  
8  
try
   {
      Runtime.getRuntime().exec("REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\your soft\key");
   }
   catch(Exception e)
   {
      System.out.println("Error ocured!");
   }


Im sure there is someway to do it using Runtime. :\

Check out my Snipping Tool++ ! An advanced snippet/screenshot/text uploading tool! Meant to replace the windows snipping tool.

Check out Pixel Rain My most recent Swing based game!
Offline davedes
« Reply #6 - Posted 2012-06-25 06:14:31 »

and I don't understand what you mean by feed the registry a prepared key..?

The reason I am looking to do this through code is because the key will be changing
every so often.
Note that your screen saver will probably need to be re-started in order for the new text to take effect.

You could programatically create a reg file like so:
1  
2  
3  
4  
5  
Header
Blank line
[RegistryPath]
"DataType"="DataValue"
Blank line


1  
2  
3  
4  
5  
Windows Registry Editor Version 5.00

[HKEY_USERS\.DEFAULT\Software\Microsoft\Screensavers\Text3D]
"DisplayString"="Your message here..."
 


More info:
http://support.microsoft.com/kb/310516

Offline Shane75776
« Reply #7 - Posted 2012-06-25 06:16:14 »

and I don't understand what you mean by feed the registry a prepared key..?

The reason I am looking to do this through code is because the key will be changing
every so often.
Note that your screen saver will probably need to be re-started in order for the new text to take effect.

You could programatically create a reg file like so:
1  
2  
3  
4  
5  
Header
Blank line
[RegistryPath]
"DataType"="DataValue"
Blank line


1  
2  
3  
4  
Windows Registry Editor Version 5.00

[HKEY_USERS\.DEFAULT\Software\Microsoft\Screensavers\Text3D]
"DisplayString"="Your message here..."


More info:
http://support.microsoft.com/kb/310516

This creates a new one, I need to edit an existing one... Unless I can overwrite registry keys? But I don't think you can.

Check out my Snipping Tool++ ! An advanced snippet/screenshot/text uploading tool! Meant to replace the windows snipping tool.

Check out Pixel Rain My most recent Swing based game!
Offline davedes
« Reply #8 - Posted 2012-06-25 06:17:45 »

I don't have my Windows nearby but as I remember REG files overwrite whatever values are there.

EDIT:
From the MS support site:
Quote
When you run a .reg file, the file contents merge into the local registry. Therefore, you must distribute .reg files with caution.

Offline Shane75776
« Reply #9 - Posted 2012-06-25 06:25:17 »

I don't have my Windows nearby but as I remember REG files overwrite whatever values are there.

EDIT:
From the MS support site:
Quote
When you run a .reg file, the file contents merge into the local registry. Therefore, you must distribute .reg files with caution.

hmm. i guess i will try the way you posted earlier and see how that works.

Check out my Snipping Tool++ ! An advanced snippet/screenshot/text uploading tool! Meant to replace the windows snipping tool.

Check out Pixel Rain My most recent Swing based game!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Shane75776
« Reply #10 - Posted 2012-06-25 06:31:26 »

I tried the following, but it seemed to do absolutely nothing. didn't change it at all.
1  
2  
3  
4  
5  
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Sofware\Microsoft\Windows\CurrentVersion\Screensavers\ssText3d]
"DisplayString"="This was edited with a reg file"
 

Check out my Snipping Tool++ ! An advanced snippet/screenshot/text uploading tool! Meant to replace the windows snipping tool.

Check out Pixel Rain My most recent Swing based game!
Offline Mads

JGO Ninja


Medals: 24
Projects: 3


One for all!


« Reply #11 - Posted 2012-06-25 13:09:31 »

I had an API once that did this. However, it was released very quietly to a small amount of people, on a server far off in the dust.
Just came here to say that a such thing exists, and someone out there has it. The library was called reglib.

It was originally posted here, but links are dead. The author is still active, so you might have some luck.
http://www.rune-server.org/programming/application-development/233446-java-registry-api.html

EDIT:
Heey! Look what I found, using this wonderful new tool that I just recently learned about. It's almost too good to be true. It's called Poogle, or something like that.
http://stackoverflow.com/questions/62289/read-write-to-windows-registry-using-java

Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #12 - Posted 2012-06-25 23:38:02 »

Java-wise, the second reply to the StackOverflow post with the very complicated class is what you want.
Command line-wise, adding a key that already exists is the same as modifying the key so REG ADD [...] is what you want.

Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #13 - Posted 2012-06-26 02:43:32 »

I think access to the registry changed slightly with windows 7 (Edit: also Vista), as I have several apps that change registry settings for other related apps, that stopped working with w7.  The symptoms were that I could write a new key, but subsequently not modify it.  Since these were not my programs (and were not java), the fix was to change the compatibility settings of the EXE to windows XP.  This might explain why the REG ADD isn't working to modify existing entries.  Edit: A quick look at regedit shows that keys have security permissions.  It may be worth checking that the security permission for the key you want to modify doesn't appear as read only for your app.  I reckon this was done to improve security, so is a good thing.

Time flies like a bird. Fruit flies like a banana.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #14 - Posted 2012-06-26 02:57:07 »

I tried the following, but it seemed to do absolutely nothing. didn't change it at all.
1  
2  
3  
4  
5  
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Sofware\Microsoft\Windows\CurrentVersion\Screensavers\ssText3d]
"DisplayString"="This was edited with a reg file"
 

How did you 'try' it?

Did you create a *.reg file and double-click it, or did you call it from Java using Runtime.getRuntime().exec("...") ?

If the latter, you should check out stdout and stderr to look for clues.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #15 - Posted 2012-06-26 04:01:18 »

I tried the following, but it seemed to do absolutely nothing. didn't change it at all.
1  
2  
3  
4  
5  
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Sofware\Microsoft\Windows\CurrentVersion\Screensavers\ssText3d]
"DisplayString"="This was edited with a reg file"
 


I noticed a typo: 'Sofware'. Might be worth checking it isn't in your code.

Edit: BTW: I also noticed that if you use REG ADD it needs a /f flag to force an overwrite without a confirm prompt.

Time flies like a bird. Fruit flies like a banana.
Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #16 - Posted 2012-06-26 04:14:21 »

Oh wow, @Shane if you did use that, make sure to delete that stray key!

Offline Shane75776
« Reply #17 - Posted 2012-06-26 08:27:07 »

I tried the following, but it seemed to do absolutely nothing. didn't change it at all.
1  
2  
3  
4  
5  
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Sofware\Microsoft\Windows\CurrentVersion\Screensavers\ssText3d]
"DisplayString"="This was edited with a reg file"
 


I noticed a typo: 'Sofware'. Might be worth checking it isn't in your code.

Edit: BTW: I also noticed that if you use REG ADD it needs a /f flag to force an overwrite without a confirm prompt.

Oh wow I feel stupid now. I read over it for spelling mistakes also and didnt even catch the missing 't'.

im pretty sure that was it.

and i tested by make a .reg file. I figured if that worked, it would work using the getRuntime way with command arguments.

Edit:
So that simple type seemed to fix my problem, it updates the key with the correct value, however, the 3dtext screen saver does not seem to want to
use that value as the text. it reverts to the default text of 'Windows 7'. possibly have to restart my computer? hmm.. ill have to look into this further
tomorrow sometime :\

Thanks for the help so far!

Check out my Snipping Tool++ ! An advanced snippet/screenshot/text uploading tool! Meant to replace the windows snipping tool.

Check out Pixel Rain My most recent Swing based game!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (16 views)
2014-04-15 18:08:23

BurntPizza (14 views)
2014-04-15 03:46:01

UprightPath (27 views)
2014-04-14 17:39:50

UprightPath (12 views)
2014-04-14 17:35:47

Porlus (29 views)
2014-04-14 15:48:38

tom_mai78101 (51 views)
2014-04-10 04:04:31

BurntPizza (110 views)
2014-04-08 23:06:04

tom_mai78101 (211 views)
2014-04-05 13:34:39

trollwarrior1 (179 views)
2014-04-04 12:06:45

CJLetsGame (185 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!