这个我以前看过例程,它是调用Shell API COM组件实现的,大量的用到平台调用服务。注册表注册都是API自动完成的,如果你用VC,VB做过类似的程序,用C#做也不难的。不知源码,找不找的到,我好好找找。找到源码前,你可以先看看Shell API,也许可以的到方法。
解决方案 »
- C# 怎么取百度注册的验证码
- 现在我想把一个XML文件的数据显示到listview中?
- 请教:如何实现Wince背光设置
- c#创建xml节点的属性出错了,而且是很奇怪的错,请大家帮忙看看!!
- 关于类型转换的问题
- 请大家帮忙,排列组合价格最低问题
- 俺是菜鸟:请各位高手进来帮俺看看! C#中的Get和set?
- 我有一个C#的Winform项目,里面有许多的程序代码....丢了.sin文件可以新建一个添加现有项目搞定,可是丢了csproj文件,怎么办呀?/
- 请问关于用c# 识别图档中的二维码(QR CODE) 有现成的第三方库可用吗?(免费或付费都可)
- 请问怎样提高C#水平?
- 那位兄弟有《C# WEB服务---使用.net remoting 和asp.net创建WEB服务》的书的原码呢???
- dispose 和 Finalize 有什么区别???
我不想靠!大家靠来靠去没意思!因为我们都是有素质的人!所以我相信我们不会轻易说脏话!
我只是想问你!修改注册表那一项!老大2天了!你不是说简单嘛!那你指点一下菜鸟是那一项!谢谢你了!!!!!!
1)打开注册表编辑器,找到HKEY_CLASSES_ROOT\Directory\shell,然后选中它,点击鼠标右键,新建一个主键,取名为“DOS”,然后选中新建的主键,在右边双击默认字符串值,在弹出的对话框中输入“用DOS窗口在这里浏览”,然后选中新建的主键,再建立一个主键,取名为“command”,选中“command”主键,修改默认值为“cmd.exe /k "cd %L"”即可。
2)检查:在任意一个文件夹上按下鼠标右键,可以在弹出的菜单里面看到“用DOS窗口在这里浏览”,选择用DOS窗口在这里浏览,按下鼠标左键,看到没有,DOS窗口弹了出来!
希望对你不所帮助
这个介绍的很详细
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”子键即变为可编辑状态,此时可将其修改为“全部由网络蚂蚁下载”,回车后,重新启动浏览器,汉化内容生效
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);
}
}
} }
}
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);
}
}
}
需要源码,[email protected]
好的。谢谢!请给份源码参看一下!是不是我要的功能!:)邮件已发给你!
不管了。在放几天搞不定的话!就只有换成“我的电脑”右键菜单启动程序了!TO: wangj2001(乡村酒吧) 谢谢你的帮助!解账时!100分答谢兄台的热心助人!:)