2025年3月17日 星期一 甲辰(龙)年 月十六 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > .net

代码库の自定义后缀名

时间:02-11来源:作者:点击数:32

代码库の自定义后缀名

  • using Microsoft.Win32; //操纵注册表的必要命名空间。
  • namespace myMethod
  • {
  • public class CreateSuffixName
  • {
  • //使程序获取被双击了的文件的路径,用到[Command]函数,可以[获取路径].
  • /// <summary>
  • /// 创建自定义后缀名的方法。
  • /// </summary>
  • /// <param name="strHouZhuiMing">以".XX"格式输入自定义后缀名</param>
  • /// <param name="strName">可以输入任意English words,建议输入公司的英文名字或软件名字</param>
  • /// <param name="strShuoMingYu">对其进行解释的说明性文字,可任意输入。</param>
  • /// <param name="strIconPath">如其名,输入显示自定义格式文件图标的路径。</param>
  • /// <param name="strEXEpath">如其名,输入用来打开该后缀名的程序路径,推荐使用相对路径。</param>
  • private static void myMethod_CreateSuffixName(string strHouZhuiMing,
  • string strName,
  • string strShuoMingYu,
  • string strIconPath,
  • string strEXEpath)
  • {
  • RegistryKey reg = Registry.ClassesRoot;
  • reg.CreateSubKey(strHouZhuiMing).SetValue("" ,strName );
  • reg.CreateSubKey(strName ).SetValue("" , strShuoMingYu );
  • reg.CreateSubKey(strName + @"\DefaultIcon").SetValue("" , strIconPath);
  • reg.CreateSubKey(strName + @"\shell\open\command").SetValue("" , strEXEpath + " %1");
  • }
  • }
  • }

 

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门