2016-07-05 115 views
5

我使用BrendanGrant.Helpers.FileAssociation;(NuGet包)爲我的應用程序創建文件關聯。到目前爲止它工作正常。然而,我與ProgramVerb個問題:爲什麼我的contextmenu輸入小寫?

當我創建一個ProgramAssociation並添加動詞來像這樣:

var pai = new ProgramAssociationInfo(fai.ProgID); 

    pai.Create(
    "App name", 
    new[] 
    { 
     new ProgramVerb("Öffnen", Assembly.GetEntryAssembly().Location + " \"%1\""), 
     new ProgramVerb("Bearbeiten", Assembly.GetEntryAssembly().Location + " \"%1\"") 
    }); 
} 

的Bearbeiten和Öffnen(編輯並打開)關鍵字的文本菜單小寫Windows資源管理器:

enter image description here

我評爲第二項WAAAA測試如果有些事只有改變的第一個字符,但顯然它不是。

我必須改變什麼,以便我的Bearbeiten和Öffnen在上下文菜單中大寫?

回答

4

我檢查了這個庫,看起來你對這種行爲沒有影響。

這是改變爲小寫行:

​​

_

protected void SetVerbs(ProgramVerb[] verbs) 
{ 
    if (!this.Exists) 
    throw new Exception("Extension does not exist"); 
    RegistryKey registryKey = RegistryHelper.AssociationsRoot.OpenSubKey(this.progId, true); 
    if (registryKey.OpenSubKey("shell", true) != null) 
    registryKey.DeleteSubKeyTree("shell"); 
    RegistryKey subKey1 = registryKey.CreateSubKey("shell"); 
    foreach (ProgramVerb verb in verbs) 
    { 
    RegistryKey subKey2 = subKey1.CreateSubKey(verb.Name.ToLower()); 
    RegistryKey subKey3 = subKey2.CreateSubKey("command"); 
    subKey3.SetValue(string.Empty, (object) verb.Command, RegistryValueKind.ExpandString); 
    subKey3.Close(); 
    subKey2.Close(); 
    } 
    ShellNotification.NotifyOfChange(); 
} 

相反,你應該使用AddVerb(ProgramVerb動詞)方法,然後大寫應保持集合分配:

pai.Create("App name", new ProgramVerb[0]); 
pai.AddVerb(new ProgramVerb("Öffnen", Assembly.GetEntryAssembly().Location + " \"%1\"")); 
pai.AddVerb(new ProgramVerb("Bearbeiten", Assembly.GetEntryAssembly().Location + " \"%1\"")); 
+2

*** A picture?!*** You posted?ap一行代碼的icture *,而不是僅僅複製和粘貼代碼行? –

+0

@PawelMaga我可以使用下面發佈的代碼而不是庫嗎?或者你碰巧知道任何其他圖書館? – Mafii

+0

@Mafii不幸的是,你不能,看看我編輯的答案。 –

相關問題