Solved

Create a EXE file to write to Registry

Posted on 2003-11-04
6
980 Views
Last Modified: 2007-12-19
Hello,
I have Jbuilder 8.1 which can create exe file.
I would like to make a exe file that writes a file to regisrty, like creating a serial number.It is a kind of licencing.How can i do it. I have no idea of writing a file to registry from java.Can anyone help me with a sample program for it.I will use that modify according to my requirement and  create a exe from jbuilder.

Rgds
Mani
0
Comment
Question by:jackiemani
6 Comments
 
LVL 92

Assisted Solution

by:objects
objects earned 30 total points
ID: 9684896
0
 
LVL 5

Accepted Solution

by:
lwinkenb earned 35 total points
ID: 9685004
Basically you have to use JNI to write to the registry, or use some 3rd party tools like the one objects posted.

If you want to write your own JNI library to do this, let me know and I can walk you through it.  
0
 
LVL 15

Assisted Solution

by:dualsoul
dualsoul earned 30 total points
ID: 9685241
just create your dll-function in C/C++ , which will write data to registry. And then use JNI to call it, and pass parameters it needs to write to registry. Thats simple :)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
LVL 15

Expert Comment

by:dualsoul
ID: 9685259
you can find good tutorial on JNI at java.sun.com
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 30 total points
ID: 9685282
0
 

Author Comment

by:jackiemani
ID: 9691563
THANKS TO ALL ,
I solved it by using preferences api.Since i have to give away points even though was not helping me to my requirement, i will split to all of u.

import java.util.prefs.Preferences;

public class UsingReg {

public static final String REALKEY= "com.hnl.htms";

public static void main(String[] args){
  new UsingReg().doit();
}

public void doit() {
  // write into HKEY_CURRENT_USER\Software\Javasoft\Prefs\com.hnl.htms
  Preferences p = Preferences.userRoot();
  p.put(REALKEY, "1234567767656590298");

  // read back from HKEY_CURRENT_USER
  System.out.println(p);
  System.out.println(p.get(REALKEY, "Error While Writing"));

  // write into HKEY_LOCAL_MACHINE\Software\Javasoft\Prefs\com.hnl.htms
  p = Preferences.systemRoot();
  p.put(REALKEY, "1234567767656590298");
 //Preferences c = Preferences.userRoot().node("com.hnl.htms/Company");
 // c.put("CmpName","Sno");
  // read back from HKEY_LOCAL_MACHINE
  System.out.println(p);
  System.out.println(p.get(REALKEY, "Error No Value"));
  }
}
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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 lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

820 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