我们为Notes 8.5.2开发了一个自定义插件。它记录了许多自定义用户首选项。这样做的类如下所示:
import java.util.prefs.Preferences;
/**
* Provides programmatic access to Windows Registry entries for this plug-in.
*/
public class Registry
{
Preferences prefs;
/**
* Initializes a new instance of the Registry class.
*/
public Registry()
{
prefs = Preferences.userNodeForPackage(Registry.class) ;
}
/**
* Gets the value of a registry key.
*
* @param keyName The name of the key to return.
*
* @return A string containing the value of the specified registry key. If a key with the specified name cannot be
* found, the return value is an empty string.
*/
public String GetValue(String keyName)
{
try
{
return prefs.get(keyName, "NA") ;
}
catch(Exception err)
{
return "" ;
}
}
/**
* Sets the value of a registry key.
*
* @param keyName The name of the registry key.
*
* @param keyValue The new value for the registry key.
*/
public void SetValue(String keyName, String keyValue)
{
try
{
prefs.put(keyName, keyValue);
prefs.flush();
}
catch(Exception err)
{
}
}
}
使用它的代码示例如下:
Registry wr = new Registry();
String setting1 = wr.GetValue("CustomSetting1");
wr.SetValue("CustomSetting1", newValue);
现在,我已经扫描了Windows注册表,并且这些设置不存在。我已将整个硬盘编入索引,但我无法在任何文件中找到这些条目。
那么,这些设置存储在哪里?
答案 0 :(得分:1)
在Windows上,Java Preferences API使用注册表作为Preferences
类的后备存储。密钥以HKEY_CURRENT_USER\Software\JavaSoft\Prefs
下的包名为根。
您的代码未指定包,因此默认情况下使用以下位置(在Windows Vista和7上测试):
HKEY_CURRENT_USER\Software\JavaSoft\Prefs\<unnamed>
Sun开发者网络上的Ray Djajadinataz有一篇名为"Sir, What is Your Preference?"的文章,您可以通过一些显示注册表位置的屏幕截图获得更多关于此API的背景信息。
我想知道您是否正在搜索密钥名称,例如CustomSetting1,而不是找到它,因为它保存为/ Custom / Setting1以注意C和S是大写的(请参阅API文档。)