Reprint, original address: http://blog.csdn.net/testcs_dn/article/details/42246969
CSharp ways to call the default browser to open a Web page
Sample interface:
Method One: Read the default browser executable file path from the registry
[CSharp]View Plain copy
- Private void button1_click (object sender, EventArgs e)
- {
- //Read the default browser executable file path from the registry
- RegistryKey key = Registry.ClassesRoot.OpenSubKey (@"http\shell\open\command\");
- string s = key. GetValue (""). ToString ();
- //s is your default browser, but with the parameters behind it, cut it off, but note that the parameters behind the different browsers are not the same!
- //"D:\Program Files (x86) \google\chrome\application\chrome.exe"--"%1"
- System.Diagnostics.Process.Start (s.substring (0, s.length-8), "http://blog.csdn.net/testcs_dn");
- }
Method Two:
[CSharp]View Plain copy
- Private void button2_click (object sender, EventArgs e)
- {
- //Call the system default browser
- System.Diagnostics.Process.Start ("explorer.exe", "http://blog.csdn.net/testcs_dn");
- }
Method Three:
[CSharp]View Plain copy
- Private void button3_click (object sender, EventArgs e)
- {
- //Call the system default browser
- System.Diagnostics.Process.Start ("http://blog.csdn.net/testcs_dn");
- }
Method Four: Call IE browser
[CSharp]View Plain copy
- Private void button4_click (object sender, EventArgs e)
- {
- //Call IE browser
- System.Diagnostics.Process.Start ("Iexplore.exe", "http://blog.csdn.net/testcs_dn");
- }
In principle, method two and method three should be the same, but the code for method Three is a little shorter.
(GO) C # several ways to call the default browser to open a Web page