1. 程式人生 > >利用register.jar讀取登錄檔資訊

利用register.jar讀取登錄檔資訊

1. 需要在jre/bin下加入檔案ICE_JNIRegistry.dll</span>
2. 需要registry.jar 
3.下載地址: http://www.trustice.com/java/jnireg/index.shtml
<pre name="code" class="java">import java.util.Enumeration;

import com.ice.jni.registry.NoSuchValueException;
import com.ice.jni.registry.Registry;
import com.ice.jni.registry.RegistryException;
import com.ice.jni.registry.RegistryKey;

public class RegisterRead {

	public static void main(String[] args) {
		RegistryKey registryKey = Registry
				.openSubkey(Registry.HKEY_LOCAL_MACHINE, "SOFTWARE",
						RegistryKey.ACCESS_ALL);

		try {
			registryKey = registryKey.openSubKey("kingsoft");
			Enumeration ele = registryKey.keyElements();
			while (ele.hasMoreElements()) {
				Object key = ele.nextElement();
				System.out.println(key);
			}
			// RegistryValue registryValue = registryKey. (String.valueOf(key));
			// // 獲得該該key對應的值
			// String result = new String(registryValue.getByteData())
			// .toString();
			// System.out.println(result);
		} catch (NoSuchValueException e) {
			e.printStackTrace();
		} catch (RegistryException e) {
			e.printStackTrace();
		}
	}

}