可能重复:
Set icon for custom right-click context menu item for all desktop shortcuts (windows explorer)
我已经在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);
}
}