修改注冊表,雙擊檔案直接打開
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); }
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/67544.html
標籤:其他
上一篇:個人開發3D應用一個多月來的困惑
下一篇:如何重寫object虛方法
