Solved

How to write a byte value to registry using java

Posted on 2013-01-21
7
481 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

789 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