C#在默认浏览器中打开网页



2012-07-11 15:03:05      我来说两句      
收藏    我要投稿

[csharp] 
using System.Text.RegularExpressions; 
using Microsoft.Win32; 
 
RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"http\shell\open\command\"); 
            string s = key.GetValue("").ToString(); 
 
            Regex reg = new Regex("\"([^\"]+)\""); 
            MatchCollection matchs = reg.Matches(s); 
 
            string filename=""; 
            if (matchs.Count > 0)   www.2cto.com
            { 
                filename = matchs[0].Groups[1].Value; 
                System.Diagnostics.Process.Start(filename, AppUtils.configSetting.WebUri); 
            } 

 

通过注册表取得默认浏览器的路径,然后用进程打开即可。

你可能感兴趣的:(C#在默认浏览器中打开网页)