Notes 插件:自定义用户设置存储在哪里?

发布于 2024-12-17 05:17:43 字数 1634 浏览 0 评论 0原文

我们为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云巢 2024-12-24 05:17:43

在 Windows 上,Java Preferences API 使用注册表因为它是 首选项 类。这些键以 HKEY_CURRENT_USER\Software\JavaSoft\Prefs 下的包名称为根。

您的代码未指定包,因此默认情况下使用以下位置(在 Windows Vista 和 7 上测试):

HKEY_CURRENT_USER\Software\JavaSoft\Prefs\<unnamed>

有一篇标题为 “先生,您的偏好是什么?”,作者: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 under HKEY_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):

HKEY_CURRENT_USER\Software\JavaSoft\Prefs\<unnamed>

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文