java读取windows注册表

来源:互联网 发布:大荆 去哪里开通网络 编辑:程序博客网 时间:2024/05/16 04:48

import com.registry.RegistryKey;
import com.registry.RegistryValue;

public class RegeditTest {

public static void readRegedit(){
   RegistryKey rk = RegistryKey.listRoots()[RegistryKey.HKEY_LOCAL_MACHINE_INDEX];
   /*RegistryKey hardware = new RegistryKey(rk, "HARDWARE");
   RegistryKey devicemap = new RegistryKey(hardware, "DEVICEMAP");
   RegistryKey serialcomm = new RegistryKey(devicemap,"SERIALCOMM");*/
   RegistryKey serialcomm = new RegistryKey(rk,"HARDWARE//DEVICEMAP//SERIALCOMM");
//   RegistryKey video = new RegistryKey(devicemap, "VIDEO");
//   System.out.println(serialcomm.get);
   RegistryValue rValue = serialcomm.getValue("
//Device//VCP0");
   System.out.println(rValue.toString());
   /*List<RegistryKey> subKeys = video.getSubKeys();
   for (RegistryKey registryKey : subKeys) {
    System.out.println(registryKey.getName());
   }*/
}
public static void main(String[] args) {
   readRegedit();
}

}