2015-09-25 38 views
3

我爲虛擬打印機創建了一個c#應用程序,但現在我正在尋找啓動我的應用程序,同時右鍵單擊任何.pdf文件或任何.doc文件如何將項目添加到窗口的上下文菜單中[僅用於pdf文件和doc文件]

總之我想在窗口的上下文菜單中添加項目,但僅限於.pdf文件和.doc文件。

請告訴我如何實現它。

在此先感謝。

+2

http://www.codeproject.com/Articles/15171/Simple-shell-context-menu –

+0

如果我的答案幫助你,請接受這個,這樣它不會浮動aro und旁邊未解答的問題。 –

回答

2

要知道什麼鍵進行修改/添加,看到這裏接受的答案: Add menu item to windows context menu only for specific filetype

添加使用C#鍵,使用的RegistryKey對象

string[] exts = {".pdf", ".doc"}; 
foreach (string ext in exts) 
{ 
    RegistryKey _key = Registry.ClassesRoot.OpenSubKey($"HKEY_CLASSES_ROOT\\{ext}\\shell", true); 
    RegistryKey newkey = _key.CreateSubKey("Use Virtual Printer"); 

    RegistryKey subNewkey = newkey.CreateSubKey("Command"); 
    subNewkey.SetValue("", "C:\\yourApplication.exe"); 
    subNewkey.Close(); 

    newkey.Close(); 
    _key.Close(); 
} 

How add context menu item to Windows Explorer for folders

修改
+1

請引用您的鏈接中的相關部分,並確保在答案中包含解釋。 – nloewen

相關問題