以编程方式更改IE设置

本文关键字:IE 设置 方式更 编程 | 更新日期: 2023-09-27 18:24:05

我正在尝试使一个添加URL的windows应用程序也成为IE的"受信任的站点"。这部分工作正常。解决方案-http://www.nakov.com/blog/2009/05/15/c-code-for-changing-internet-explorer-security-settings-and-net-security-policy-to-run-windows-forms-based-activex-with-full-trust/

但我也需要更改相同的设置。我需要这个:"跨域访问数据源"需要为"启用"下载未签名的ActiveX控件"需要为"提示"初始化和编写未标记为安全的ActiveX控件"需要为"启用"

这就是我所拥有的,但它不起作用

    private void UpdateDataSource() 
    {
        RegistryKey ChangeSettings = Registry.Users;
        ChangeSettings = ChangeSettings.OpenSubKey(".DEFAULT''Software''Microsoft''Windows''CurrentVersion''Internet Settings''Zones''2", true);
        // "Access data sources across domains" - "Enable" 
        ChangeSettings.SetValue("1406", "0", RegistryValueKind.DWord);
        // "Download unsigned ActiveX controls" - "Prompt" 
        ChangeSettings.SetValue("1004", "1", RegistryValueKind.DWord);
        // "Initialize and script ActiveX controls not marked as safe for scripting" - "Enable" 
        ChangeSettings.SetValue("1201", "0", RegistryValueKind.DWord);
        ChangeSettings.Close();
    }

来源http://www.hohmanns.de/

以编程方式更改IE设置

试试这个,它有效:

private void UpdateDataSource()      
{         
    RegistryKey ChangeSettings = Registry.CurrentUser.OpenSubKey(@"Software''Microsoft''Windows''CurrentVersion''Internet Settings''Zones''3", true);          
    // "Access data sources across domains" - "Enable"          
    ChangeSettings.SetValue("1406", "0", RegistryValueKind.DWord);          
    // "Download unsigned ActiveX controls" - "Prompt"          
    ChangeSettings.SetValue("1004", "1", RegistryValueKind.DWord);          
    // "Initialize and script ActiveX controls not marked as safe for scripting" - "Enable"          
    ChangeSettings.SetValue("1201", "0", RegistryValueKind.DWord);          
    ChangeSettings.Close();    
}

您可以访问此网站:http://networkdog.blogspot.com/2011/04/internet-explorer-9-configurations.html关于internet explorer 9注册表项。您可以找到所有配置密钥。

您可以尝试在IE中手动更改它,然后检查注册表中更改了什么,并找到更改它的方法(直接更改注册表),或者找到更改特定标记的更好方法。

太棒了,它很管用。。这是关键:

RegistryKey ChangeSettings=Registry.CurrentUser.EOpenSubKey(@"Software''Microsoft''Windows''CurrentVersion''Internet Settings''Zoness''3",true);