如何使用C#在Internet Explorer中更改主页?

JJo*_*ohn 5 c#

是否可以在C#应用程序中更改Internet Explorer中的主页?其他浏览器(Firefox,Chrome)的解决方案也不错.

nun*_*cal 11

那么,对于IE,你必须设置注册表项:

HKCU\Software\Microsoft\Internet Explorer\Main\Start Page
Run Code Online (Sandbox Code Playgroud)

对于firefox,您需要编辑js文件:prefs.js.这可以在以下位置找到:C:\Users\ [USERNAME]\AppData\Roaming\Mozilla\Firefox\Profiles\ [User Subfolder]

Chrome,将数据存储在 C:\Users\<username>\AppData\Local\Chromium\User Data\Default文件夹中的Preferences文件夹中.这是JSON格式.编辑它不应该是麻烦


Har*_*tts 5

Internet Explorer 的主页保存在Start Page注册表项中HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main(根据),因此您可以使用以下Registry中的类来设置它Microsoft.Win32(从此示例中):

RegistryKey startPageKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main", true);
startPageKey.SetValue("Start Page", "http://stackoverflow.com");
startPageKey.Close();
Run Code Online (Sandbox Code Playgroud)

恐怕不知道其他人怎么样。