zoukankan      html  css  js  c++  java
  • Windows Explorer中对所选文件增加右键菜单并关联自己程序的例子

    为选中文件注册右键菜单

             private void registerFile()

            {
                if (this.txtName.Text.Length == 0) return;
                // 注册到文件
                //if (this.ckRegToFile.Checked)
                //{
                    RegistryKey shell = Registry.ClassesRoot.OpenSubKey("*", true).OpenSubKey("shell", true);
                    if (shell == null)
                    {
                        shell = Registry.ClassesRoot.OpenSubKey("*", true).CreateSubKey("shell");
                    }
                    
                    RegistryKey custome = shell.CreateSubKey(this.txtName.Text);
                    RegistryKey cmd = custome.CreateSubKey("command");

                    //下边为你想关联的程序可以是任何语言写的任何程序 

                    //D:\Projects\ContextMenu\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
                    string executePath = @txtAppPath.Text;
                   

                    //Application.ExecutablePath

                    //%1 代表所选文件全路径 如c:\abcd.pdf

                    cmd.SetValue("", executePath + " %1");
                    cmd.Close();
                    custome.Close();
                    shell.Close();
                    MessageBox.Show("Register sucessfully!", "Notification"); 
                //}
            }
  • 相关阅读:
    django2.2/mysql ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
    orm练习题
    url的匹配问题
    集成抽象类后出现的问题
    迅为IMX6Q开发板上移植mplayer
    迅为i.MX6ULL开发板原理图分析介绍
    性价比高又能较好的学习嵌入式ARM+Linux的开发板
    适合初学者的linux开发板
    IMX6ULL开发板
    i.MX6ULL开发板终结者资料介绍
  • 原文地址:https://www.cnblogs.com/jjj250/p/2059061.html
Copyright © 2011-2022 走看看