Solved

How to write a byte value to registry using java

Posted on 2013-01-21
7
482 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Way to decrease size of apk file 9 104
jsp error 6 43
junit as external jar or library 7 37
Tomcat 9 + java 8 error while trying to deploy a war file 2 689
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
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 if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

740 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