Created
June 20, 2014 23:13
-
-
Save fredrikhaglund/43aea7522f9e844d3e7b to your computer and use it in GitHub Desktop.
Launch Chrome from C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static class ChromeLauncher | |
{ | |
private const string ChromeAppKey = @"\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe"; | |
private static string ChromeAppFileName | |
{ | |
get | |
{ | |
return (string) (Registry.GetValue("HKEY_LOCAL_MACHINE" + ChromeAppKey, "", null) ?? | |
Registry.GetValue("HKEY_CURRENT_USER" + ChromeAppKey, "", null)); | |
} | |
} | |
public static void OpenLink(string url) | |
{ | |
string chromeAppFileName = ChromeAppFileName; | |
if (string.IsNullOrEmpty(chromeAppFileName)) | |
{ | |
throw new Exception("Could not find chrome.exe!"); | |
} | |
Process.Start(chromeAppFileName, url); | |
} | |
} |
HI Fredrikhaglund,
can you some help .. I want google chrome in my windows application
Great~!!!
Why don't you want to use single one line
Process.Start("chrome.exe", url);
instead?
Why don't you want to use single one line
Process.Start("chrome.exe", url);
instead?
Because that requires the Chrome folder being in the PATH environment variable
Works great thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Part of my blog post How to open a link in another browser.