• c#创建文件关联


    try
                    {
                        string MyFileName = AppSetter.SysInfoPath + @"\DrawTools\csg.exe";
                        string MyExtName = ".csg";
                        string MyType = "csgfile";
                        RegistryKey key = Registry.ClassesRoot.OpenSubKey(MyExtName);
                        if (key == null || key.ValueCount == 0)
                        {
                            RegistryKey MyReg = Registry.ClassesRoot.CreateSubKey(MyExtName);
                            MyReg.SetValue("", MyType);
                            MyReg = MyReg.CreateSubKey("shell\\open\\command");
                            MyReg.SetValue("", MyFileName + " %1");
                            MyReg.Close();
                        }
                        else if (!key.GetValue("").ToString().Equals(MyType))
                        {
                            key.DeleteSubKeyTree(MyExtName);
                            RegistryKey MyReg = Registry.ClassesRoot.CreateSubKey(MyExtName);
                            MyReg.SetValue("", MyType);
                            MyReg = MyReg.CreateSubKey("shell\\open\\command");
                            MyReg.SetValue("", MyFileName + " %1");
                            MyReg.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        Tools.Trace("Program:Main error:" + ex.ToString());
                    }

  • 相关阅读:
    【重学计算机】计组D2章:数据表示
    【重学计算机】计组D1章:计算机系统概论
    计算机底层原理杂谈(白话文)
    阿里云安装wordpress遇到的问题
    wordpress数据表结构
    家用计费系统ER图
    java 类中的属性为什么一般都是私有的
    centos 软件库安装
    linux下启动tomcat----Cannot find ./catalina.sh
    jfreechart图表汉字乱码问题解决方案
  • 原文地址:https://www.cnblogs.com/kongll/p/2555717.html
Copyright © 2020-2023  润新知