string strProject = "Exec";
string p_FileTypeName =".cdb";//文件后綴
string fileName = System.Windows.Forms.Application.ExecutablePath;// 獲取啟動(dòng)了應(yīng)用程序的可執(zhí)行文件的路徑及文件名
//string startPath = System.Windows.Forms.Application.StartupPath;//獲取啟動(dòng)了應(yīng)用程序的可執(zhí)行文件的路徑
//注冊(cè)文件類型
Registry.ClassesRoot.CreateSubKey(p_FileTypeName).SetValue("", strProject, RegistryValueKind.String);
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(strProject))
{
//設(shè)置圖標(biāo)
RegistryKey iconKey = key.CreateSubKey("DefaultIcon");
iconKey.SetValue("", System.Windows.Forms.Application.StartupPath + "\\ooopic_1564036072.ico");
//設(shè)置默認(rèn)啟動(dòng)程序
key.CreateSubKey(@"Shell\Open\Command").SetValue("", fileName + " \"%1\"", RegistryValueKind.ExpandString);
}