如何在windows xp的上下文菜单中添加图标?

时间:2013-01-22 09:20:31

标签: c# windows-xp registry shell-extensions

  

可能重复:
  Set icon for custom right-click context menu item for all desktop shortcuts (windows explorer)

Context menu

我已经在Windows XP中成功创建了上下文菜单,我想在上下文菜单中添加图标,如图所示。我已经阅读了关于上下文菜单的文献但却失败了。你能帮助我吗?谢谢。

private void registryMenuContextFolder(string menuName, string pathApp, string pathIcon)

{

        try
        {

            RegistryKey _key = Registry.ClassesRoot.OpenSubKey("Folder\\Shell", true);

            RegistryKey _keyFolder = _key.CreateSubKey(menuName);
            if (_keyFolder != null)
            {
                _keyFolder.SetValue("Icon",Application.ExecutablePath +",0");

            }
            RegistryKey _keyCmd = _keyFolder.CreateSubKey("Command");
            if (_keyCmd != null)
            {
                _keyCmd.SetValue("", pathApp);
            }
            _keyCmd.Close();
            _keyFolder.Close();
            _key.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

0 个答案:

没有答案