如何在C#中以编程方式更改Internet Explorer辅助功能设置

时间:2015-01-18 13:03:20

标签: c# internet-explorer

我需要更改Internet Explorer选项 - 辅助功能 - 用户样式表,以便在晚上注意我的眼睛,使用此css样式表:

* {background-image: none !important;background: none !important;background:#333333 !important;color:#888888!important;border-color:#555555 !important;
scrollbar-arrow-color:#CCCCCC !important;scrollbar-base-color:#2266AA !important;scrollbar-shadow-color:#2266AA !important;scrollbar-face-color:#333333 !important;scrollbar-highlight-color:#2266AA !important;scrollbar-dark-shadow-color:#2266AA !important;scrollbar-3d-light-color:#2266AA !important;scrollbar-track-color:#333333 !important;}
a,a *{color:#88AADD !important;text-decoration:none !important;}a:visited,a:visited *,a:active,a:active *{color:#5588AA !important;}
a:hover,a:hover *{color:#AADD88 !important;background:#666666 !important;}input,select,option,button,textarea{color:#AAAAAA !important;background:#555555 !important;
border:#666666 !important;border-color: #666666 #888888 #888888 #666666 !important;}input:focus,select:focus,option:focus,button:focus,textarea:focus,input:hover,
select:hover,option:hover,button:hover,textarea:hover {color:#BBBBBB !important;background:#5A5A5A !important;border-color: #777777 #999999 #999999 #777777 !important;}
input[type=button],input[type=submit],input[type=reset],input[type=image] {border-color: #888888 #666666 #666666 #888888 !important;}input[type=button]:focus,
input[type=submit]:focus,input[type=reset]:focus,input[type=image]:focus, input[type=button]:hover,input[type=submit]:hover,input[type=reset]:hover,input[type=image]:hover {
color:#BBBBBB !important;background:#666666 !important; border-color: #AAAAAA #888888 #888888 #AAAAAA !important;}

现在我已经完成了大部分代码,并且代码运行良好,就像这样

 RegistryKey reg = Registry.CurrentUser.CreateSubKey(@"SoftWare\Microsoft\Internet Explorer\Styles");
            reg.SetValue("User Stylesheet", @"d:\style.css");
            reg.SetValue("Use My Stylesheet", "1", RegistryValueKind.DWord);

问题是我需要重启IE或打开newTab然后更改生效,我知道,它类似于代理设置

我已经尝试了代码

[DllImport("wininet.dll", SetLastError = true)]
    private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lPBuffer, int lpdwBufferLength);
    private const int INTERNET_OPTION_REFRESH = 0x000025;
    private const int INTERNET_OPTION_SETTINGS_CHANGED = 0x000027;
    private void Reflush()
    {
            InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
            InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
    }

但它对IE辅助功能设置不起作用。如何在不重启IE的情况下更改辅助功能设置?

0 个答案:

没有答案