Solved

How to write a byte value to registry using java

Posted on 2013-01-21
7
479 Views
Last Modified: 2013-01-28
Hi all.
I need to write a byte value to registry using java.


I use this code in vb.net.

 Dim RegKey As Microsoft.Win32.RegistryKey =Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\Microsoft\Internet Explorer\Main")
Dim IEDispBinarySetting As Byte() = {&H2C, 0, 0, 0, 2, 0, 0, 0, _
                                                3, 0, 0, 0, &HFF, &HFF, &HFF, &HFF, _
                                                &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, _
                                                &HFF, &HFF, &HFF, &HFF, 0, 0, 0, 0, _
                                                &H1E, 0, 0, 0, &H1D, 3, 0, 0, _
                                                &HDE, 2, 0, 0}

 RegKey.SetValue("Window_Placement", IEDispBinarySetting)




How do I  set a byte value to windows registry using java??
give me code!
0
Comment
Question by:HFunakawa
7 Comments
 
LVL 30

Accepted Solution

by:
IanTh earned 167 total points
ID: 38804156
0
 
LVL 16

Assisted Solution

by:Valeri
Valeri earned 167 total points
ID: 38804307
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 166 total points
ID: 38805170
Let us know how you get on with those and we can look into the binary write
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 16

Expert Comment

by:Valeri
ID: 38805194
you have to use putByteArray to achieve the same
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38805201
The first thing you need to do is to ensure that you can get to the right key. The Preferences api is very restricted in that respect
0
 

Author Comment

by:HFunakawa
ID: 38825388
thank you for everyone and sorry for late.


i made a program from those sample.
like this

 private static byte[] toCstr(String str) {
                byte[] result = new byte[str.length() + 1];

                for (int i = 0; i < str.length(); i++) {
                  result = (byte) str.charAt(i);
                }
                result[str.length()] = 0;
                return result;
              }


      byte[] a=toCstr("&H2C, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, &HFF, 0, 0, 0, 0, &H1E, 0, 0, 0, &H1D, 3, 0, 0, &HDE, 2, 0, 0");
    Advapi32Util.registrySetBinaryValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\Main", "Window_Placement", a);


im not so sure its right..
anyway it worked so thanks for all your help.



0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38828130
im not so sure its right..
It isn't ;) You need something different to get the right array, so if that's an issue, please open a new question
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what is a "java.lang.System Property"   ? 20 65
hibernate example for saving data 19 37
How do I remove an object from a 3 24
String array comparison 4 32
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

776 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