c#修改預設瀏覽器
阿新 • • 發佈:2019-02-14
/* *修改預設瀏覽器 */ //瀏覽器路徑 string exePath = @"F:\firefox\firefox.exe"; //登錄檔項 string reg = @"http\shell\open\command"; string nameReg = @"http\shell\open\ddeexec\Application"; RegistryKey key = null; try { key = Registry.ClassesRoot.OpenSubKey(reg, true); if (key != null) { key.SetValue("", string.Format("\"{0}\" -- \"%1\"", exePath)); key.Close(); key = Registry.ClassesRoot.OpenSubKey(nameReg, true); if (key != null) { key.SetValue("", Path.GetFileNameWithoutExtension(exePath)); key.Close(); } } } catch (Exception) { key.Close(); }