2011-11-17 72 views
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注册表,而且这些设置不存在。我已经索引了我的整个硬盘,并且我无法在任何文件中找到这些条目。

那么,这些设置存储在哪里?

回答

1

在Windows上,Java Preferences API使用Registry作为Preferences类的后备存储。密钥根据包名称根据HKEY_CURRENT_USER\Software\JavaSoft\Prefs

您的代码没有指定一个包,所以它默认使用以下位置(在Windows Vista和测试7):

HKEY_CURRENT_USER\Software\JavaSoft\Prefs\<unnamed> 

有一个在Sun开发者雷Djajadinataz题为"Sir, What is Your Preference?"的articled网络,您可以通过一些显示注册表位置的屏幕快照获取更多关于此API的背景信息。

我不知道你是否正在寻找按键的名称,如CustomSetting1,并没有发现它,因为它被保存为/自定义/设置1值得注意的是,C和S是大写(见API文档。)

+0

当然够了,那就是他们所在的地方。他们被怪异地命名。非常感谢! –

相关问题