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