2016-07-05 114 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不幸的是,你不能,看看我编辑的答案。 –

相关问题