2011-11-17 192 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

當然夠了,那就是他們所在的地方。他們被怪異地命名。非常感謝! –