Solved

How to write a byte value to registry using java

Posted on 2013-01-21
7
477 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now