代码库の自定义后缀名
- 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");
- }
- }
- }