Search code examples
javawindowsregistry

How to write an entry (valueName and value) in Windows Registry


Similar question was already ask here and there're a lot of good answers. I choosed the piece of code from the 1. answer and with given good example could read some value from Windows Registry (WR). Can anyone give me a good example please to write an entry (valueName and Value) in WR? I'm not familiar with Java and that's why it's a little complicated for me to understand it without example:( The main Key is HKEY_LOCAL_MACHINE, Subkey is Software\\Wow6432Node\\mySoft. The valueName and value that I want to write are: myPwd and a. Thanks!


Solution

  • Please refer back to the same link here first answer to use the provided class WinRegistry, and then you can use its function writeStringValue

    For example, in your case:

    WinRegistry.writeStringValue( WinRegistry.HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\mySoft", "myPwd", "a" );