(200分)在问!如何修改桌面右键菜单!

nyucv 2003-12-13 07:11:26
我想在桌面右键菜单中增加新项!点击该菜单项时。启动我的程序!!
(如:江民杀毒王。大哥们是:桌面右键菜单呀!*********不是我的电脑,文件夹,文件的右键菜单!*******。我查了很多资料也没找到在注册表中要修改那一项才能实现!谁知道要修改那项!200分答谢!!!!!!绝不失言!失言是四只脚的!呵呵!!!!!!)
谢谢!!!!!!!!!!!!!!!!
...全文
2085 31 打赏 收藏 转发到动态 举报
写回复
用AI写文章
31 条回复
切换为时间正序
请发表友善的回复…
发表回复
nyucv 2003-12-31
  • 打赏
  • 举报
回复
UP!!!!!!!
有人知道吗?
nyucv 2003-12-29
  • 打赏
  • 举报
回复

不管了。在放几天搞不定的话!就只有换成“我的电脑”右键菜单启动程序了!

TO: wangj2001(乡村酒吧) 谢谢你的帮助!解账时!100分答谢兄台的热心助人!:)
nyucv 2003-12-28
  • 打赏
  • 举报
回复
楼上兄台:谢谢你的源码!不过好像桌面右键菜单中还是没有新增加菜单项呀!55555555555
wangj2001 2003-12-22
  • 打赏
  • 举报
回复
源码在我家内机器上,我晚上下班回去给你发
Vicky020923 2003-12-21
  • 打赏
  • 举报
回复
gz
nyucv 2003-12-21
  • 打赏
  • 举报
回复
TO:wangj2001(乡村酒吧)
好的。谢谢!请给份源码参看一下!是不是我要的功能!:)邮件已发给你!
wangj2001 2003-12-20
  • 打赏
  • 举报
回复
using System;
using System.Windows.Forms;
using System.Drawing;

namespace ShellLinks
{
/// <summary>
/// This is the shell links demonstration application
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Button BtnExit;
private bool Skip;
private System.Windows.Forms.CheckBox chkRunOnStartup;
private System.Windows.Forms.CheckBox chkSendToLink;
private System.Windows.Forms.CheckBox chkQuickLaunch;
private System.Windows.Forms.CheckBox chkDesktopLink;
private string QuickLaunchDir;


public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

// Set check buttons depending on whether shortcuts exist on the desktop and in the startup folder
Skip=true; // Don't run the CheckedChanged code
chkRunOnStartup.Checked=Link.Exists(Environment.SpecialFolder.Startup,"Shell Link");
chkDesktopLink.Checked=Link.Exists(Environment.SpecialFolder.DesktopDirectory,"Shell Link");
chkSendToLink.Checked=Link.Exists(Environment.SpecialFolder.SendTo,"Shell Link");
QuickLaunchDir=Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
+ "\\Microsoft\\Internet Explorer\\Quick Launch";
chkQuickLaunch.Checked=Link.Exists(QuickLaunchDir,"Shell Link");
Skip=false;
}

public void Exit()
{
Application.Exit();
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.chkDesktopLink = new System.Windows.Forms.CheckBox();
this.chkRunOnStartup = new System.Windows.Forms.CheckBox();
this.chkQuickLaunch = new System.Windows.Forms.CheckBox();
this.BtnExit = new System.Windows.Forms.Button();
this.chkSendToLink = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// chkDesktopLink
//
this.chkDesktopLink.Checked = true;
this.chkDesktopLink.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkDesktopLink.Location = new System.Drawing.Point(8, 64);
this.chkDesktopLink.Name = "chkDesktopLink";
this.chkDesktopLink.Size = new System.Drawing.Size(184, 24);
this.chkDesktopLink.TabIndex = 3;
this.chkDesktopLink.Text = "Put Shortcut on the Desktop";
this.chkDesktopLink.CheckedChanged += new System.EventHandler(this.chkDesktopLink_CheckedChanged);
//
// chkRunOnStartup
//
this.chkRunOnStartup.Checked = true;
this.chkRunOnStartup.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkRunOnStartup.Location = new System.Drawing.Point(8, 40);
this.chkRunOnStartup.Name = "chkRunOnStartup";
this.chkRunOnStartup.Size = new System.Drawing.Size(176, 24);
this.chkRunOnStartup.TabIndex = 2;
this.chkRunOnStartup.Text = "Start Automatically at Login";
this.chkRunOnStartup.CheckedChanged += new System.EventHandler(this.chkRunOnStartup_CheckedChanged);
//
// chkQuickLaunch
//
this.chkQuickLaunch.Checked = true;
this.chkQuickLaunch.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkQuickLaunch.Location = new System.Drawing.Point(8, 16);
this.chkQuickLaunch.Name = "chkQuickLaunch";
this.chkQuickLaunch.Size = new System.Drawing.Size(176, 24);
this.chkQuickLaunch.TabIndex = 1;
this.chkQuickLaunch.Text = "Show in Quick Launch Area";
this.chkQuickLaunch.CheckedChanged += new System.EventHandler(this.chkQuickLaunch_CheckedChanged);
//
// BtnExit
//
this.BtnExit.BackColor = System.Drawing.SystemColors.Control;
this.BtnExit.Cursor = System.Windows.Forms.Cursors.Arrow;
this.BtnExit.DialogResult = System.Windows.Forms.DialogResult.Abort;
this.BtnExit.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.BtnExit.Location = new System.Drawing.Point(192, 48);
this.BtnExit.Name = "BtnExit";
this.BtnExit.Size = new System.Drawing.Size(48, 23);
this.BtnExit.TabIndex = 11;
this.BtnExit.Text = "E&xit";
this.BtnExit.Click += new System.EventHandler(this.BtnExit_Click);
//
// chkSendToLink
//
this.chkSendToLink.Checked = true;
this.chkSendToLink.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkSendToLink.Location = new System.Drawing.Point(8, 88);
this.chkSendToLink.Name = "chkSendToLink";
this.chkSendToLink.Size = new System.Drawing.Size(160, 24);
this.chkSendToLink.TabIndex = 12;
this.chkSendToLink.Text = "Add to SendTo Menu";
this.chkSendToLink.CheckedChanged += new System.EventHandler(this.chkSendToLink_CheckedChanged);
//
// MainForm
//
this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.BtnExit;
this.CausesValidation = false;
this.ClientSize = new System.Drawing.Size(258, 127);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.chkSendToLink,
this.BtnExit,
this.chkDesktopLink,
this.chkRunOnStartup,
this.chkQuickLaunch});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MainForm";
this.Text = "Demonstrate Shell Links";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}



public void BtnExit_Click(object sender, System.EventArgs e)
{
Exit();
}


/// <summary>
/// This method checks the startup directory to see if there is a link to the executable file
/// it modifies the directory accordingly depending on the setting of the RunOnStartup checkbox
/// </summary>
private void chkRunOnStartup_CheckedChanged(object sender, System.EventArgs e)
{
if(Skip)return;
Link.Update(Environment.SpecialFolder.Startup,Application.ExecutablePath,"Shell Link",chkRunOnStartup.Checked);
}

// Update a link to the executable on the desktop depending on the setting of chkDesktopLink
private void chkDesktopLink_CheckedChanged(object sender, System.EventArgs e)
{
if(Skip)return;
Link.Update(Environment.SpecialFolder.DesktopDirectory,Application.ExecutablePath,"Shell Link",chkDesktopLink.Checked);
}

private void chkSendToLink_CheckedChanged(object sender, System.EventArgs e)
{
if(Skip)return;
Link.Update(Environment.SpecialFolder.SendTo,Application.ExecutablePath,"Shell Link",chkSendToLink.Checked);
}

private void chkQuickLaunch_CheckedChanged(object sender, System.EventArgs e)
{
if(Skip)return;
Link.Update(QuickLaunchDir,Application.ExecutablePath,"Shell Link",chkQuickLaunch.Checked);
}
}
}
需要源码,gangleader@126.com
wangj2001 2003-12-20
  • 打赏
  • 举报
回复
演示怎样操作右键菜单,左面快捷方式,开始菜单
namespace ShellLinks
{
public class Link
{
/// <summary>
/// Check to see if a shortcut exists in a given directory with a specified file name
/// </summary>
/// <param name="DirectoryPath">The directory in which to look</param>
/// <param name="FullPathName">The name of the shortcut (without the .lnk extension) or the full path to a file of the same name</param>
/// <returns>Returns true if the link exists</returns>
public static bool Exists(string DirectoryPath, string LinkPathName)
{
// Get some file and directory information
DirectoryInfo SpecialDir=new DirectoryInfo(DirectoryPath);
// First get the filename for the original file and create a new file
// name for a link in the Startup directory
FileInfo originalfile = new FileInfo(LinkPathName);
string NewFileName = SpecialDir.FullName+"\\"+originalfile.Name+".lnk";
FileInfo linkfile = new FileInfo(NewFileName);
return linkfile.Exists;
}
//Check to see if a shell link exists to the given path in the specified special folder
// return true if it exists
public static bool Exists(Environment.SpecialFolder folder, string LinkPathName)
{
return Link.Exists(Environment.GetFolderPath(folder), LinkPathName);
}
/// <summary>
/// Update the specified folder by creating or deleting a Shell Link if necessary
/// </summary>
/// <param name="folder">A SpecialFolder in which the link will reside</param>
/// <param name="TargetPathName">The path name of the target file for the link</param>
/// <param name="LinkPathName">The file name for the link itself or, if a path name the directory information will be ignored.</param>
/// <param name="Create">If true, create the link, otherwise delete it</param>
public static void Update(Environment.SpecialFolder folder, string TargetPathName, string LinkPathName, bool install)
{
// Get some file and directory information
Link.Update(Environment.GetFolderPath(folder), TargetPathName, LinkPathName, install);
}

// boolean variable "install" determines whether the link should be there or not.
// Update the folder by creating or deleting the link as required.

/// <summary>
/// Update the specified folder by creating or deleting a Shell Link if necessary
/// </summary>
/// <param name="DirectoryPath">The full path of the directory in which the link will reside</param>
/// <param name="TargetPathName">The path name of the target file for the link</param>
/// <param name="LinkPathName">The file name for the link itself or, if a path name the directory information will be ignored.</param>
/// <param name="Create">If true, create the link, otherwise delete it</param>
public static void Update(string DirectoryPath, string TargetPathName, string LinkPathName, bool Create)
{
// Get some file and directory information
DirectoryInfo SpecialDir=new DirectoryInfo(DirectoryPath);
// First get the filename for the original file and create a new file
// name for a link in the Startup directory
//
FileInfo OriginalFile = new FileInfo(LinkPathName);
string NewFileName = SpecialDir.FullName+"\\"+OriginalFile.Name+".lnk";
FileInfo LinkFile = new FileInfo(NewFileName);

if(Create) // If the link doesn't exist, create it
{
if(LinkFile.Exists)return; // We're all done if it already exists
//Place a shortcut to the file in the special folder
try
{
// Create a shortcut in the special folder for the file
// Making use of the Windows Scripting Host
WshShell shell = new WshShell();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(LinkFile.FullName);
link.TargetPath=TargetPathName;
link.Save();
}
catch
{
MessageBox.Show("Unable to create link in special directory: "+NewFileName,
"Shell Link Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
else // otherwise delete it from the startup directory
{
if(!LinkFile.Exists)return; // It doesn't exist so we are done!
try
{
LinkFile.Delete();
}
catch
{
MessageBox.Show("Error deleting link in special directory: "+NewFileName,
"Shell Link Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
}

}
}
snowflake310 2003-12-20
  • 打赏
  • 举报
回复
我顶
zj492 2003-12-20
  • 打赏
  • 举报
回复

kangzerun 2003-12-20
  • 打赏
  • 举报
回复
我顶
nyucv 2003-12-20
  • 打赏
  • 举报
回复
自已顶!问题还是没解决!:(
nyucv 2003-12-19
  • 打赏
  • 举报
回复
谢谢楼上各位兄的解答!
是呀!***************我要修改的是桌面右键菜单。比如:在桌面右键菜单中忝加“我的程序员”。当用户在桌面点击右键------我的程序员时。就起动应用软件!*************
什么目录,文件,我的电脑,一类的右键菜单我能搞定!桌面右键菜单搞不定!请帮助!
13880079673 2003-12-18
  • 打赏
  • 举报
回复
楼上的没有明白楼主的意思,如果是修改文件夹的右健菜单,那就太简单,随便在网上找一下就能找到。
但是桌面右健就不样,很少看到软件能在桌面右健菜单加自己的东西。楼主说的江民杀毒王我没用过
wswc3110 2003-12-18
  • 打赏
  • 举报
回复
修改注册表
13880079673 2003-12-18
  • 打赏
  • 举报
回复
晕倒,回贴的看清楚楼主意思再说,不要再弄些没用的东西上来,是桌面右健,不是文件右健,老大些,动动脑子吧
veaven 2003-12-18
  • 打赏
  • 举报
回复
简单的方法
http://tech.sina.com.cn/c/2002-01-16/8472.html

修改注册表 打造个性化右键菜单

  鼠标右键菜单中有很多快捷命令,给用户日常操作带来了极大的方便。但是,不知您注意到没有,当鼠标右键菜单弹出的时候,其中的项目是否合您心意呢?是不是有的命令您并不需要,而您需要的却又不在上面呢?或者是英文选项使您不知其意……哈,如果糊里糊涂地使用右键命令,肯定不能提高工作效率。那就让我们略施小计,让鼠标右键菜单命令真正为己所用吧。


  以下方法,主要通过编辑注册表来实现,所以请一定事先备份注册表。方法是:点击“开始/运行”,填入“regedit”打开注册表编辑器,选择“导出注册表文件”就可以了。

  添加右键命令

  您所希望使用的命令如果不在右键菜单中,就要靠我们自己把它“加”进去。让我们来看几个添加实例,把握了基本方法,就可触类旁通,添加一切命令。


图1 用右键快捷命令重启计算机。

  “重新启动计算机”是经常需要做的工作,可是它的实现要通过点击“开始/关闭系统/重新启动计算机/确定”好几个步骤的操作,比较麻烦,如果可以通过右键快捷命令随时随地重启就更方便了。要添加“重新启动计算机”到右键菜单中,方法是:打开注册表编辑器,定位到“HKEY_LOCAL_MACHINE\Software\CLASSES\Directory\shell”,在其下新建一个名为“Restart”的子键,然后双击右侧窗口中的“默认”,将数值设为“重新启动计算机”。接下来,在“Restart”子键下再建一个子项,命名为“command”,双击右侧窗口中的“默认”,将数值设为“C:\WINDOWS\RUNDLL.EXE USER.EXE,EXITWINDOWSEXEC”。回车退出后,鼠标右键单击任意文件夹或“开始”按钮,在弹出的菜单中,用户就可以选择“重新启动计算机”命令了(如图1)。

  除了“回收站”本身,其他文件的右键菜单都没有“清空回收站”命令,那么我们也可以给它加上。在“HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers”下新建主键“{645FF040-5081-101B-9F08-00AA002F954E}”,确定后退出注册表,当右击任何文件时,其快捷菜单都会有一个“清空回收站”的选项。

  删除右键命令

  右键菜单选项良莠不齐,一些没用的命令应毫不留情地删除。在上网时常会遇到IE首页或标题栏被更改的情况,对此大家已经见怪不怪了。可是最近又有一种新的源代码,在右键菜单把自己的网站名字加上,在你用右键的时候就会出现在弹出的菜单中,虽然不影响使用,但一个不怎么样的网站实在不值得留在右键菜单中,而且长长的右键菜单也有碍雅观。去掉它的办法是:打开注册表编辑器,找到“HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt”,你就会看到令人讨厌的网址,将其删除,右键就不会再出现那些网站的名字了。

  有时我们正常卸载某个应用程序后,在右键菜单中仍会遗留下一些不再需要的项目,同样需要将其删除。这些遗留项目一般都存放在“HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers”;如果是只对文件夹有效的项目,则存放在“HKEY_CLASSES_ROOT\Directory\shell”和“HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers”,有时在“HKEY_CLASSES_ROOT\Folder\shell”和“HKEY_CLASSES_ROOT\Folder\shellex\ContextMenuHandlers”也有,找到后将他们删除即可。

  不想让右键菜单显示怎么办呢?比如要禁止右键单击“开始”弹出的菜单。在“HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer”下新建键值“NoTrayContextMenu”,赋值为“1”,这样在“开始”按钮上单击右键时就不会出现快捷菜单。

  汉化右键命令

  有时在一些程序中使用右键时,所弹出的右键菜单中一些命令用英文显示,如果英文不好就会“一头雾水”。其实,它们是可以汉化的。比如安装了网络蚂蚁后,当用户浏览网页时如果单击鼠标右键,会发现在菜单中多了“Download All by NetAnts”,感到它和其他的中文选项有点不谐调。汉化它的办法是:打开注册表编辑器,定位到“HKEY_CURRENT_USER\Soft-ware\Microsoft\Internet Explorer\MenuExt\Download &&All by NetAnts”,再用鼠标右键单击“Download &&All by NetAnts”子键,在出现的快捷菜单中选择“重命名”,则“Download &&All by NetAnts”子键即变为可编辑状态,此时可将其修改为“全部由网络蚂蚁下载”,回车后,重新启动浏览器,汉化内容生效

veaven 2003-12-18
  • 打赏
  • 举报
回复
http://www.vckbase.com/document/viewdoc.asp?id=827
这个介绍的很详细
laodeng72586 2003-12-17
  • 打赏
  • 举报
回复
我不会,但是找了一个资料给你参考参考:

修改鼠标右键菜单

我们知道在98下可以通过注册表来修改鼠标右键菜单,其实在WinXP中也可以。方法如下:这里以在鼠标右键菜单上添加“用DOS窗口在这里浏览”为例。
1)打开注册表编辑器,找到HKEY_CLASSES_ROOT\Directory\shell,然后选中它,点击鼠标右键,新建一个主键,取名为“DOS”,然后选中新建的主键,在右边双击默认字符串值,在弹出的对话框中输入“用DOS窗口在这里浏览”,然后选中新建的主键,再建立一个主键,取名为“command”,选中“command”主键,修改默认值为“cmd.exe /k "cd %L"”即可。
2)检查:在任意一个文件夹上按下鼠标右键,可以在弹出的菜单里面看到“用DOS窗口在这里浏览”,选择用DOS窗口在这里浏览,按下鼠标左键,看到没有,DOS窗口弹了出来!

希望对你不所帮助
jun_01 2003-12-17
  • 打赏
  • 举报
回复
呵呵,这么看来,的确很难喽
加载更多回复(11)

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧