调用系统默认浏览器,打开网页
作者:互联网
使用Process.Start("http://www")有些系统会无效,所以,这样比较保险
string HTTP_KEY = @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice"; if (true) { var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(HTTP_KEY, false); var progid = key.GetValue("ProgId").ToString(); key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey($"{progid}\\shell\\open\\command",false); var value = key.GetValue(null); if (value != null) { var path = value.ToString(); if (path.StartsWith("\"")) { var exePath = path.Substring(1); var index = exePath.IndexOf("\""); exePath = exePath.Substring(0, index); index += 2; var args = path.Substring(index); args = args.Replace("%1", "https://www.baidu.com"); System.Diagnostics.Process.Start(exePath, args); return; } } }
标签:index,网页,args,默认,key,path,var,浏览器,exePath 来源: https://www.cnblogs.com/IWings/p/14659407.html