class1.cs

来自「150个经典的入门学习程序源代码」· CS 代码 · 共 47 行

CS
47
字号
using System;
using Microsoft.Win32;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace Example102_修改系统的右键菜单
{
	/// <summary>
	/// Class1 的摘要说明。
	/// </summary>
	class Class1
	{
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			//
			// TODO: 在此处添加代码以启动应用程序
			//
			
			if(args.Length>0)
			{
				Console.Write(args[0]);
				Console.Read();
			}
			else
			{
				Process p=Process.GetCurrentProcess();
				

				AssemblyName an=new AssemblyName();
				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();
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?