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
private void Button1_Click (object sender, EventArgs e) { //Read the default browser executable 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, 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:
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:
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
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.
Sample code Download:
C # Several ways to invoke the default browser to open a Web page
C # Several ways to invoke the default browser to open a Web page