个人代码库の自定义后缀名

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");
}
}
}
作者:Asion Tang
凡是没有注明[转载]的文章,本Blog发表的文章版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/AsionTang/p/1885713.html