2012-02-10 168 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」,真正的);