2012-02-10 165 views
3

我正在尝试制作一个Windows应用程序,它也为IE添加了一个URL“可信站点”。这部分工作。 解决方案 - 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/更改IE设置以编程方式

但我需要更改相同的设置。我需要这个: “跨域访问数据源”需要“启用” “下载未签名的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/

+1

这听起来像:*“我如何降低IE中用户帐户的每个安全设置?”*。更不用说如果通过组策略设置安全性,您将无法做到这一点。 – slugster 2012-02-10 10:32:36

+0

Slugster - 你有链接到“如何降低用户帐户的IE中的每个安全设置?”也许它可以帮助我 – LuckyDice 2012-02-10 10:41:56

+2

哈哈。在发布链接@slugster之后,也许你可以找到*“我如何绕过操作系统中的所有安全功能?”*它必须存在,正确@Simon? – adelphus 2012-02-10 10:55:33

回答

0

您可以尝试手动更改它在IE浏览器,然后检查什么是在注册表中更改,找到一种方法通过直接更改注册表来改变它,或者找到一个改变特定标签的方式。

+3

这应该是一个评论,而不是一个答案。 – slugster 2012-02-10 10:29:58

+0

已经尝试过,看到注册表中的更改。但我看不到它 – LuckyDice 2012-02-10 10:36:23

+0

@slugster:好的,谢谢...我想这说明了所有(部分)答案或答案的方向? – 2012-02-10 10:37:38

2

试试这个,它的工作原理:

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();  
} 
+0

这确实对我有用..谢谢..创建一个控制台程序并运行代码。该设置立即反映出来, – Shubh 2016-07-16 16:29:34

+0

@Rohit,谢谢你的回答。对于更改Microsoft Office设置(更改编号设置为上下文模式),我遇到同样的问题。你有什么主意吗? – 2016-12-17 08:23:09

0

好极了,它的工作原理。这是关键:

的RegistryKey ChangeSettings = Registry.CurrentUser.OpenSubKey(@ “软件\微软\的Windows \ CurrentVersion \ Internet设置\区\ 3”,真正的);