我需要编写用于编码UI测试的功能,当第一次打开浏览器Internet Explorer时,禁用弹出窗口。那么如何在c#上以编程方式执行此操作?是否需要编辑一些注册?
答案 0 :(得分:1)
基于http://www.petenetlive.com/KB/Article/0000175.htm,我们应该将注册表项设置为:
在C#中,我们应该可以这样做:Windows注册表编辑器版本5.00
[HKEY_LOCAL_MACHINE \ Software \ Policies \ Microsoft \ Internet Explorer \ Main]“DisableFirstRunCustomize”= dword:00000001
var key = Registry.LocalMachine.OpenSubKey("SOFTWARE", true)
.OpenSubKey("Policies", true)
.OpenSubKey("Microsoft", true);
key = key.OpenSubKey("Internet Explorer", true) ?? key.CreateSubKey("Internet Explorer", RegistryKeyPermissionCheck.ReadWriteSubTree);
key = key.OpenSubKey("Main", true) ?? key.CreateSubKey("Main", RegistryKeyPermissionCheck.ReadWriteSubTree);
key.SetValue("DisableFirstRunCustomize", 1, RegistryValueKind.DWord);