using System;
using Microsoft.Win32;
using System.Diagnostics;
namespace 在系统菜单中添加命令
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
if(args.Length>0)
{
Console.WriteLine(args[0]);
Console.Read();
}
else
{
Process p=Process.GetCurrentProcess();
RegistryKey RegKey;
RegKey=Registry.ClassesRoot;
RegKey=RegKey.CreateSubKey("*//shell//MyApp");
RegKey.SetValue("","What is this?");
RegKey=Registry.ClassesRoot;
RegKey=RegKey.CreateSubKey("*//shell//MyApp//command");
RegKey.SetValue("",p.MainWindowTitle+"%1");
RegKey.Close();
}
}
}
}
本文介绍了一种使用C#编程语言来实现在Windows系统的上下文菜单中添加自定义命令的方法。通过注册表操作,可以在右键菜单中增加一项,用于启动指定的应用程序。
3万+

被折叠的 条评论
为什么被折叠?



