应用程序安装位置注册表在 Software\Microsoft\Windows\CurrentVersion\App Paths 下
如下列浏览器安装位置:
chrome:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe
Firefox:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe
Edge:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe
360极速浏览器:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\360chrome.exe
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\360chrome.exe
搜狗浏览器未在上述位置找到,故采用应用程序卸载程序位置查找程序入口
应用程序卸载程序位置注册表在 HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall 下
搜狗浏览器程序入口在卸载程序同目录下,名为 SogouExplorer.exe
调用搜狗浏览器代码如下:
private static bool OpenSogouBrowserUrl(string url)
{
try
{
// 通过注册表找到搜狗高速浏览器安装路径
RegistryKey regkey = Registry.LocalMachine;
RegistryKey registrykey = regkey.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\SogouExplorer");
string uninstallpath = (string)registrykey.GetValue("UninstallString");
string path = uninstallpath.Substring(0, uninstallpath.LastIndexOf('\\'));
string sogouAppFileName = path + @"\SogouExplorer.exe";
if (String.IsNullOrWhiteSpace(sogouAppFileName))
return;
// 打开搜狗高速浏览器
Process.Start(sogouAppFileName, url);
return;
}
catch(Exception ex)
{
System.Windows.Forms.MessageBox.Show("异常信息:" + ex.Message + "\n异常对象:" + ex.Source + "\n调用堆栈:" + ex.StackTrace.Trim() + "\n触发方法:" + ex.TargetSite);
return;
}
}