我已经在 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);
}
}