zoukankan      html  css  js  c++  java
  • Associate extension with c# exe

    Code as follow:

        public static class AssociateExtensionHelper
        {
            public static void CreateExtension(string extension, string commandPath)
            {
                string operationkeyName = "Do" + extension;
                var key = Registry.ClassesRoot.CreateSubKey(extension);
                key.SetValue(null, operationkeyName);
    
                var operationkey = Registry.ClassesRoot.CreateSubKey(operationkeyName);
                var defaultIcon = operationkey.CreateSubKey("DefaultIcon");
                defaultIcon.SetValue(null, "%SystemRoot%\\SysWow64\\imageres.dll,-103");
    
                var shellKey = operationkey.CreateSubKey("shell");
                var openKey = shellKey.CreateSubKey("Open");
                var commandKey = openKey.CreateSubKey("command");
                commandKey.SetValue(null, commandPath);
            }
        }

    Call as this :

    AssociateExtensionHelper.CreateExtension(".abc", @"E:\MyDemo\MyDemo\AssociateExtension\bin\Debug\AssociateExtension.exe %1");
  • 相关阅读:
    python---模块与包
    python---迭代器与生成器
    python---装饰器
    Python---函数
    Python---文件操作
    Python---数据类型
    浅谈UBUNTU
    java 键盘输入多种方法
    动态规划解最长公共子序列问题
    线段树
  • 原文地址:https://www.cnblogs.com/xiaokang088/p/2997399.html
Copyright © 2011-2022 走看看