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();
}
}
本文提供了一个Java示例程序,演示了如何通过Java代码读取Windows注册表中的特定值。示例中展示了如何定位到'HARDWAREDEVICEMAPSERIALCOMM'路径并获取指定项的值。
719

被折叠的 条评论
为什么被折叠?



