void updateHomePage(EngineModel model) { // IE 使用修改注册表的方式,key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main // chromium 内核系列的浏览器使用修改配置文件 Secure Preferences 的方式 Regex chromeVersionRe = new Regex(@"^\d+\.\d+\.$", RegexOptions.IgnoreCase | RegexOptions.Singleline); foreach (KeyValuePair <string, IWshShortcut> kv in selectedBrowsers) { if (kv.Key == "iexplore.exe") { Console.WriteLine(wsh.RegRead(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main")); //wsh.RegWrite(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", model.MainPage); } else { foreach (var fileInfo in Directory.GetParent(kv.Value.TargetPath).GetFiles()) { //C:\Users\mysto\AppData\Local\Google\Chrome\User Data\Default\Secure Preferences if (chromeVersionRe.IsMatch(fileInfo.Name)) { // chrome } } } } }
/// <summary> /// Gets the environment variable. /// </summary> /// <param name="varName">Name of the variable.</param> /// <param name="varType">Type of the variable.</param> /// <returns></returns> public string GetEnvironmentVariable(string varName, EnvironmentVariableTarget varType) { object objValue = shell.RegRead(RegistryKey(varType) + varName); return(objValue.ToString()); }