c# 调用浏览器打开网址

 string liulanqi = ""; ;
            try
            {
                //从注册表中读取默认浏览器可执行文件路径
                var key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(@"http\shell\open\command\");
                string s = key.GetValue("").ToString();
                //s就是你的默认浏览器,不过后面带了参数,把它截去,不过需要注意的是:不同的浏览器后面的参数不一样!
                //"D:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -- "%1"
                liulanqi = s.Substring(1, s.Length - 10);
            }
            catch{}
            if (string.IsNullOrWhiteSpace(liulanqi))
                liulanqi = "iexplore.exe";
            var urlData = "www.baidu.com";
            string url = string.Format("{0}'{1}'", urlData.G_Remark, _AttrCustomer["C_ID"].ToString());
            if(!File.Exists(liulanqi))
            {
                liulanqi = "iexplore.exe";
            }
            System.Diagnostics.Process.Start(liulanqi, url);

 

posted @ 2021-09-30 17:36  世人皆萌  阅读(633)  评论(0编辑  收藏  举报