//工具启动路径
string toolPath = System.Windows.Forms.Application.StartupPath + "\\邮件小工具.exe";
string extension = SptdConst.FileExtension;
string fileType = "Email File";
string fileContent = "text/plain";
//获取信息
Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(extension);
if (registryKey != null && registryKey.OpenSubKey("shell") != null && registryKey.OpenSubKey("shell").OpenSubKey("open") != null &&
registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command") != null)
{
var varSub = registryKey.OpenSubKey("shell").OpenSubKey("open").OpenSubKey("command");
var varValue = varSub.GetValue("");
if (Object.Equals(varValue, toolPath + " %1"))
{
return;
}
}
//删除
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(extension, false);
//文件注册
registryKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(extension);
registryKey.SetValue("文件类型", fileType);
registryKey.SetValue("Content Type", fileContent);
//设置默认图标
Microsoft.Win32.RegistryKey iconKey = registryKey.CreateSubKey("DefaultIcon");
iconKey.SetValue("", System.Windows.Forms.Application.StartupPath + "\\logo.ico");
//设置默认打开程序路径
registryKey = registryKey.CreateSubKey("shell\\open\\command");
registryKey.SetValue("", toolPath + " %1");
//关闭
registryKey.Close();
//双击启动打开
//如果原有路径中存在空格,则会分解成多个元素
if (e.Args.Length > 0)
{
string filePath = String.Join(" ", e.Args.ToArray());
FileInfo file = new FileInfo(filePath);
if (file.Exists)
{
EmailToolConst.DoubleClickSptdFilePath = file.FullName;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有