ads_header

How To Customize Registry File In Netbeans


How To Customize Registry File In Netbeans



Preview



Hello friends, in this post I will discuss about Registry in Windows Operating SystemThe Registry is a hierarchically arranged database that supports information about the configuration of a system from hardware, software to user preferences. So later we will read, add and remove registry in Registry Editor


In the picture above I have a sub folder with the name of Tutorial in HKEY_CURRENT_USER folder, in that folder we will process the registry using form in Netbeans.

First open Netbeans and create a new project and add "some" components in the form including one jTextField and three jButtons.


If done, import some librabry we need

import javax.swing.JOptionPane;
import ca.beq.util.win32.registry.RegistryException;   
import ca.beq.util.win32.registry.RegistryKey;
import ca.beq.util.win32.registry.RegistryValue;
import ca.beq.util.win32.registry.RootKey;
import ca.beq.util.win32.registry.ValueType;

Then, double-click jButton1 and enter the code to add a registry in accordance with the contents of jTextField1


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
    try{
 RegistryKey r = new RegistryKey(RootKey.HKCU,"Tutorial");
 RegistryValue v = new RegistryValue(jTextField1.getText(), ValueType.REG_SZ, "Your Value");   
 JOptionPane.showMessageDialog(null, "Registry Added");
 r.setValue(v);
    }catch(Exception e){
 JOptionPane.showMessageDialog(null, e);
 } 
}

Next, double-click jButton2 and enter the code to read the registry, whether existing or not in accordance with the contents of jTextField1.

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt){   
    try{
 RegistryKey r = new RegistryKey(RootKey.HKCU,"Tutorial");
 if(r.hasValue(jTextField1.getText()){
    JOptionPane.showMessageDialog(null, "Registry Already");
 }
 else{
    JOptionPane.showMessageDialog(null, "Registry Not Found");
 }
 
    }catch(Exception e){
 JOptionPane.showMessageDialog(null, e);
 }
}

And finally double-click jButton3 and enter the code to delete the registry in accordance with the contents of jTextField1

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt){
    try{
 RegistryKey r = new RegistryKey(RootKey.HKCU,"Tutorial");
 RegistryValue v = new RegistryValue(jTextField1.getText(), ValueType.REG_SZ, "Your Value");   
 JOptionPane.showMessageDialog(null, "Registry Deleted");
 r.deleteValue(jTextField1.getText());
    }catch(Exception e){
 JOptionPane.showMessageDialog(null, e);
 } 
}

When done and there is no error, the program is ready to run.

For more details, please watch the video below

No comments:

Powered by Blogger.