Following registry keys hold default browser’s application path
1. HKEY_CLASSES_ROOT\http\shell\open\command
2. HKEY_LOCAL_MACHINE\SOFTWARE\Classes\http\shell\open\command
As expected there is no consistency here. We tested following browsers
- Microsoft Internet Explorer 8.0.6001.18702
- Mozilla Firefox 3.0.7
- Google Chrome 1.0.154.53
- Opera 9.63
- Apple Safari 3.2.1 (525.27.1)
First options works for all browsers except Safari. Second option is not very much recommended. Following code snippet extracts browser path from open command.
using System.Text.RegularExpressions;
using Microsoft.Win32;
RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(@"\http\shell\open\command");
string[] valnames = regKey.GetValueNames();
string val0 = (string)regKey.GetValue(valnames[0]);
Regex regex = new Regex("[\\w\\W\\d]*.exe\"",RegexOptions.IgnoreCase);
Match match = regex.Match(val0);
MessageBox.Show(match.Value);
No comments:
Post a Comment