gpt4 book ai didi

java - 有谁知道如何使用 JNI-Registry (com.ice.jni.registry) 为键设置默认注册表值?

转载 作者:行者123 更新时间:2023-11-29 08:18:37 33 4
gpt4 key购买 nike

我目前正在尝试通过 Java 应用程序查询和设置一些 Windows 注册表项。我们被授权使用 JNI-Registry 库(出于许可原因)。要设置的键和值不在我的控制之下(我正在修改由另一个第 3 方应用程序设置的值)。

我可以为普通键和值获取和设置各种条目和值 OK,我可以查询键 OK 的默认值。但是,我需要知道如何设置键的默认值。

//This works
final RegistryKey regKey = Registry.HKEY_LOCAL_MACHINE.openSubKey("SOFTWARE\\company\\app\\subkey", RegistryKey.ACCESS_ALL);
RegStringValue blah = (RegStringValue) regKey.getValue("blah");
if (blah == null) {
blah = new RegStringValue(regKey, "blah");
}
blah.setData("Some data");
regKey.setValue(blah);

//Not sure about this...
final RegistryKey regKey = Registry.HKEY_LOCAL_MACHINE.openSubKey("SOFTWARE\\company\\app\\subkey", RegistryKey.ACCESS_ALL);
String defaultValue = regKey.getDefaultValue(); //Gets the default value OK
//How do I reset it, though???
//need something like:
// regKey.setDefaultValue("Some new value");

//The following does not seem to work
RegDWordValue defVal = (RegDWordValue) regKey.getValue(""); //Also tried ...getValue("Default")
defVal.setData("Some new Value");
regKey.setValue(defVal);

regKey.closeKey();

有人知道这是否可行吗?

最佳答案

是的,有可能。

好吧,在 C# 中,对于任何键,你都可以做

key.SetValue("", "value");

无名键是默认键。

这记录在:http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.setvalue.aspx (页面存档here)

有点晚了,我知道。仍然,希望它能帮助别人。我一直在寻找同样的东西。

关于java - 有谁知道如何使用 JNI-Registry (com.ice.jni.registry) 为键设置默认注册表值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2370486/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com