Atitit. Operation registry Tree Database history Java version Class library summary

Source: Internet
Author: User

Atitit. History of Operation Registry tree database Registry Java Version Class Library summary

1. The registry is a tree-shaped database 1

2. Origin of the Registration Form 1

3. Java Operations Registry 2

3.1. Using the Preferences API (Limited access Path) 2

3.2. Using JNI3

3.3. Jregistrykey recommended 4

3.4. Jregistry 4

4. Org.openqa.selenium.os.WindowsUtils 4

4.1. and Process Management 4

1. The registry is a tree-shaped database

Tree database, but does not provide a SQL-like query interface

2. Origin of the registration form

In the Windows 3.x operating system, the registry is a minimal file whose file name is Reg.dat, which contains only certain file types

Default open mode as set by the registry

Application Association, most of the settings are placed in Win.ini, System.ini, and many other initialization ini files. Because these initialization files are not easy to manage and maintain, there are some problems that the system cannot start because the INI file has been damaged. To make the system more stable and robust, Windows 95/98 designers borrowed the idea of the registry in Windows NT, introduced the registry to the Windows 95/98 operating system, and ported most of the settings in the INI file to the registry, so The registry plays an important role in the startup and operation of the Windows 95/98 operating system.

Author:: Old Wow's paw attilax Ayron, email:[email protected]

Reprint please indicate source: Http://blog.csdn.net/attilax

3. Javaoperating the Registration form3.1. UsePreferences API(Limited access Path)

Because Java program is "Write once, run everywhere", read and write the registry with Java, the program's cross-platform is poor. Java operation of the Registry, in the previous version of jdk1.4, that is not possible, can only be implemented with  JNI, however, the Prefs package provided after jdk1.4 can operate the Windows registry, but the root is dead in software/ Javasoft /prefs, it is also due to this dilemma, but also to ensure that the so-called platform-independent, and to take care of everyone's reliance on Windows

. and  JDK  provide operation   WINDOWS    API  preferences API  WIN32  HKCU\SOFTWARE\JAVASOFT  HKLM\SOFTWARE\JAVASOFT 

Free access to the registry other key values are not available in Java , the inevitable solution is JNI,

The Preferences API is not designed to access the Windows Registry, which is a point to note.

The reason we have the above misunderstanding is becauseSunof theWindowsversion ofJDKin implementingPreferences APIwhen using theWindowsRegistry as a repository, that is, we use thePreferences APIthe stored data is saved to theWindowsregistry, soPreferenes APIand there's a visit.Windowsthe ability to register the table. But to other platforms or other vendors 'JDKWhat about the implementation? This question is andPreferences APIwe have no way to answer the relevant implementation.

If the program does not care about the details of the repository, just find a place to store the data, then the Preferences API is appropriate.

Preferences API is also limited, please consider two issues:

· OneJavasoftware, this time I'm inSunof theJDKrun and use thePreferences APISave my personal preferences, next time I'm inIBMof theJDKMy personal preferences can also bePreferences APIGet it? May or may not be, the behavior at this time is determined by theSunand theIBMof thePreferences APIimplementation of the decision. (In the sameJDKimplementations can use thePreferences APIto share data between different programs)

· A Java software needs to let the user set up with the operating system to start, similar requirements are many. Such a requirement is the ability of a Java program to have a real and relevant operating system to work together. This capability is not A design goal of the Preferences API.

There are two ways in which Java reads and writes to the registry:
1. Packages in the java.util.prefs.*
where Preferences.systemroot () gets the hkey_local_machine/software/javasoft/prefs can easily read and write the registry under this position
Preferences.userroot () Gets the hkey_local_user/software/javasoft/prefs that can be registered at this location

But for other
Location operation is not convenient.
Example code:
Import java.util.prefs.*;
public class Registery {
String[] keys = {"AAA", "BBB", "CCC"};
String[] values = {"1", "2", "3"};
Store the corresponding values in a variable.
public void WriteValue () {
Write the registry value under Hkey_local_machine/software/javasoft/prefs.
Preferences pre = Preferences.systemroot (). Node ("/javaplayer");
for (int i = 0; i < keys.length; i++) {
Pre.put (keys, values);
}
}
public static void Main (string[] args) {
Registery reg = new Registery ();
Reg.writevalue ();
}
}
The result of executing the code inserts three key values in the Hkey_local_machine/software/javasoft/prefs/javaplayer location

3.2. UseJNI

The Windows operating system provides APIsto operate the registry, so using JNI to Java and these APIs Together we get the ability to operate the registry with Java. This is a little easier to say, but it takes a lot of detail to get it to work. Fortunately this kind of work has already been done and we want to thank them. Let's take a look at one of the packages below.

Com.ice.jni.registrypackage is throughJNI (Java native Interface)implementation ofWindowsRegistry ActionsAPIthat can be used to access, modify, and exportWindowsRegistration Form. Now that the bag has been made public, you can use it with confidence without worrying about it.Licenseand includes a built-inDLLand theJava,Cthe source code. It can be used inJava 1.1and a higher version of the work.

2. Open source Read and write Registry library registry-3.1.3 home Address:http://www.trustice.com/java/jnireg/index.shtml
After download, you need to put Ice_jniregistry.dll in the bin directory of the JDK you are currently using.

3.3. Jregistrykey recommended 3.4. Jregistry

Jregistry accesses the Windows Registry API through JNI technology.

4. Org.openqa.selenium.os.WindowsUtils

Writeintregistryvalue

Writestringregistryvalue

Runregquery

4.1. and Process Management

public static void Main (string[] args) throws Exception {

Line 50:public static void Tracewith (Logger log) {

Line 54:public static void Killbyname (String name) {

Line 58:public static void Trytokillbyname (String name) {

Line 68:public static void Kill (String[] cmdarray) throws Exception {

Line 126:private static void Killpid (String processID) {

Line 131:public static map<string, string> Procmap () throws Exception {

Line 171:public static synchronized Properties loadenvironment () {

Line 182:public static String Getprogramfilespath () {

Line 186:public static String Getprogramfiles86path () {

Line 190:private static string Getenvvarpath (string Envvar, string defaultvalue) {

Line 201:public static immutablelist<string> getpathsinprogramfiles (String childpath) {

Line 207:private static string GetFullPath (string parent, string child) {

Line 211:public static String Getlocalappdatapath () {

Line 220:public static string Getenvvarignorecase (string var) {

Line 230:public static File Findsystemroot () {

Line 250:public static String findwmic () {

Line 267:public static File Findwbem () {

Line 280:public static String Findtaskkill () {

Line 295:public static String Findreg () {

Line 319:public Static Boolean IsRegExeVersion1 () {

Line 330:public static class<?> Discoverregistrykeytype (String key) {

Line 358:public static string Readstringregistryvalue (String key) {

Line 384:public static int readintregistryvalue (String key) {

Line 418:public Static Boolean readbooleanregistryvalue (String key) {

Line 431:public Static Boolean doesregistryvalueexist (String key) {

Line 452:public static void Writestringregistryvalue (string key, String data)

Line 477:private static string ExecuteCommand (String commandName, string[] args) {

Line 489:public static void Writeintregistryvalue (String key, int data) {

Line 517:public static void Writebooleanregistryvalue (String key, Boolean data) {

Line 521:public static void Deleteregistryvalue (String key) {

Line 540:private static string Runregquery (String key) {

Line 556:public Static Boolean thisiswindows () {

Line 560:private Static class Regkeyvalue {

Reference

Atitit. Structure of various data types (tree structure,) and storage database Attilax summary. doc

Atitit. Operation registry Tree Database history Java version Class library summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.