C#调用浏览器(默认和非默认浏览器)

调用 IE:

System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "iexplore.exe";
myProcess.StartInfo.Arguments = " http://www.net0and1.com/";
myProcess.Start();

调用默认浏览器:
    string target= "http://www.net0and1.com";
    //Use no more than one assignment when you test this code.
    //string target = "ftp://ftp.microsoft.com";
    //string target = "C:\\Program Files\\Microsoft Visual Studio\\INSTALL.HTM";

    try
        {
         System.Diagnostics.Process.Start(target);
        }
    catch
        (
         System.ComponentModel.Win32Exception noBrowser)
        {
         if (noBrowser.ErrorCode==-2147467259)
          MessageBox.Show(noBrowser.Message);
        }
    catch (System.Exception other)
        {
          MessageBox.Show(other.Message);
        }
posted @ 2009-06-10 23:51  随便取个名字算了  阅读(2330)  评论(2编辑  收藏  举报