I have a method from an existing .NET Framework project that gets the path to the default browser in Windows from the Registry and launches it with a Process
call:
string browser = "";
RegistryKey regKey = null;
try
{
regKey = Registry.ClassesRoot.OpenSubKey("HTTP\\shell\\open\\command", false);
browser = regKey.GetValue(null).ToString().Replace("" + (char)34, "");
if (!browser.EndsWith(".exe"))
browser = browser.Substring(0, browser.LastIndexOf(".exe") + 4);
}
finally
{
if (regKey != null)
regKey.Close();
}
ProcessStartInfo info = new ProcessStartInfo(browser);
info.Arguments = "\"" + url + "\"";
Process.Start(info);
This project is trying to get setup to go cross-platform, so I'm porting it to .NET Standard (1.2). The problem is that I'm not sure what the .NET Standard equivalents are to RegistryKey
and Process
(and ProcessStartInfo
). Of course, being for other platforms, there may not be a registry or any concept of "processes" on that system. So is there a way to achieve the above functionality in .NET Standard? (Or perhaps this is an X-Y Problem and I'm going about it all wrong?)