打开谷歌浏览器的时候窗口小 (谷歌浏览器无法上网)

一、获取谷歌浏览器chrome*ex.e**路径

方法一:

/// <summary>
/// 通过ChromeHTML协议寻找
/// 在Chrome安装在计算机上时,它会安装ChromeHTML URL协议,可以使用它来到Chrome*ex.e**的路径。
/// </summary>
/// <returns></returns>
public string GetChromePath()
 {
     RegistryKey regKey = Registry.ClassesRoot;
     string path = "";
     string chromeKey = "";
     foreach (var chrome in regKey.GetSubKeyNames())
     {
         if (chrome.ToUpper().Contains("CHROMEHTML"))
         {
             chromeKey = chrome;
         }
     }
     if (!string.IsNullOrEmpty(chromeKey))
     {
         path = Registry.GetValue(@"HKEY_CLASSES_ROOT\" + chromeKey + @"\shell\open\command", null, null) as string;
         if (path != null)
         {
             var split = path.Split('\"');
             path = split.Length >= 2 ? split[1] : null;
         }
     }
     return path;
 }

方法二:

/// <summary>
/// 通过注册表获取chrome*ex.e**的路径,有些系统环境获取不到
/// </summary>
/// <param name="exeName"></param>
/// <returns></returns>
public string GetChromePath(string exeName)
{
    try
    {
        string app = exeName;
        RegistryKey regKey = Registry.LocalMachine;
        RegistryKey regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + app, false);
        object objResult = regSubKey.GetValue(string.Empty);
        RegistryValueKind regValueKind = regSubKey.GetValueKind(string.Empty);
        if (regValueKind == Microsoft.Win32.RegistryValueKind.String)
        {
            return objResult.ToString();
        }
        else
        {
            return "";
        }
    }
    catch
    {
        return "";
    }
}

二、调用打开指定网站

string path = GetChromePath();
System.Diagnostics.Process.Start(path, "https://www.toutiao.com/i7028090805420065313/");