C# 呼叫瀏覽器 (Browser)


在編寫軟件時常常會用到連結到自己的網站..
以下是在一個網站中找到的代碼,我將他改了一下..應該比較好處理..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System.Diagnostics;  
using Microsoft.Win32;

private void copyRight()
{
string browser = string.Empty;
RegistryKey key = null;

try
{
key = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false);
browser = key.GetValue(null).ToString().ToLower().Replace("\"", "");

if (!browser.EndsWith("exe"))
{
browser = browser.Substring(0, browser.LastIndexOf(".exe")+ 4);
}
}
finally
{
if (key != null) key.Close();
}

System.Diagnostics.ProcessStartInfo parms = new ProcessStartInfo(browser,"http://skhk.uni.cc/");
System.Diagnostics.Process.Start(parms);
}