반응형
자바로 개인 프로젝트를 하다가 윈도우의 레지스트리에 접근하려고 자료를 찾아봤습니다.
일반적으로 시스템쪽을 컨트롤 하려면 JNI를 사용해야 되는것 같더군요.
일단 레지스트리 컨트롤 할 수 있는 라이브러리 관련 자료 정리해 봅니다.(JNI를 이용하여)

http://www.bayequities.com/tech/projects.shtml  <-- 사이트가 사라진듯..안되는군요 ^^;
사용자 삽입 이미지

jRegistryKey is a Java™ Native Interface (JNI) wrapper around the Microsoft® Windows® Win32® application programming interface (API) registry functions, designed to facilitate Windows® registry access for Java™ developers. jRegistry Key User Manual

ClassPath에 포함시킬 파일들 입니다.

invalid-file

jRegistryKey.dll





예제소스입니다.

import ca.beq.util.win32.registry.*;

public class AppMain
{
    public AppMain()
    {
        super();
    }

    public static void main(String[] args)
    {
        RegistryKey r = new RegistryKey(RootKey.HKEY_LOCAL_MACHINE, "Software\\Ncsoft\\L2Client");
       
        String key = "workingdir";
        if(r.hasValue(key))
        {
           RegistryValue v = r.getValue(key);
           String value = v.toString();
           value = value.replaceAll(v.getName()+":", "").replaceAll("REG_SZ:", "").replaceAll("REG_DWORD:", "");
           System.out.println("lineage2 working dir : " + value);
   
           RegistryValue vs = r.getValue("global_version");
           System.out.println(vs.toString());
        }
        else
            System.out.println("Not Existed Key");
    }
}


레지스트리 편집기를 이용하여 값과 결과 화면을 확인해 보세요.^^
--------------------------------------------------------------------------------------------------------------------------------------
밑에 자료는 다른 패키지를 이용하는 방법이다.

Windows Registry API Native Interface

Release 3.1.3, September 11, 2003

The com.ice.jni.registry package is a Java native interface for the Windows Registry API. This allows Java program to access, modify, and export Windows Registry resources.

The com.ice.jni.registry package has been placed into the public domain. Thus, you have absolutely no licensing issues to consider. You may do anything you wish with the code. Of course, I always appreciate it when you properly credit my work.

The package will work only with Java 1.1 and greater, and uses the Javasoft native interface, not the Netscape interface. The package also includes a DLL that implements the interface. The package has been used with JDK1.2, and JDK1.3, JDK1.4, as well as JDK1.1.8.

The package includes the pre-built DLL (debug and release), source code (both the Java and the DLL's C code), as well as the compiled Java classes.

The original release was posted on November 17, 1997. The current release is 3.1.3, which was posted on September 11, 2003.

http://www.trustice.com/java/jnireg/index.shtml   <-- 여기에서 다운받으면 된다.

--------------------------------------------------------------------------------------------------------------------------------------

http://sourceforge.net/projects/java-registry/   <-- 이것도 다른 패키지인듯...

+ Recent posts