Notes 插件:自定义用户设置存储在哪里?
我们为 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 注册表,发现这些设置不存在。我已经对我的整个硬盘建立了索引,但在任何文件中都找不到这些条目。
那么,这些设置到底存储在哪里呢?
We've developed a custom plugin for Notes 8.5.2. It records a number of custom user preferences. The class that does so is shown below:
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)
{
}
}
}
A sample of the code that uses it is as follows:
Registry wr = new Registry();
String setting1 = wr.GetValue("CustomSetting1");
wr.SetValue("CustomSetting1", newValue);
Now, I've scanned the Windows Registry, and these settings do not exist. I've indexed my entire hard disk, and I cannot find these entries in any file.
So, where the heck are these settings being stored?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Windows 上,Java Preferences API 使用注册表因为它是
首选项
类。这些键以HKEY_CURRENT_USER\Software\JavaSoft\Prefs
下的包名称为根。您的代码未指定包,因此默认情况下使用以下位置(在 Windows Vista 和 7 上测试):
有一篇标题为 “先生,您的偏好是什么?”,作者:Sun Developer Network 的 Ray Djajadinataz,您可以通过一些屏幕截图了解此 API 的更多背景信息注册表位置。
我想知道您是否正在搜索键名称,例如 CustomSetting1,但没有找到它,因为它被保存为 /Custom/Setting1 以注意 C 和 S 是大写的(请参阅 API 文档。)
On Windows the Java Preferences API uses the Registry as it's backing store for the
Preferences
class. The keys are rooted by package name underHKEY_CURRENT_USER\Software\JavaSoft\Prefs
.Your code doesn't specify a package, so it uses the following location by default (tested on Windows Vista and 7):
There is an articled titled "Sir, What is Your Preference?" by Ray Djajadinataz at the Sun Developer Network where you can get a little more background on this API with some screen shots showing registry locations.
I wonder if you were searching for the key name, eg CustomSetting1, and not finding it because it is saved as /Custom/Setting1 to note that the C and S are capitalized (see API docs.)