ASP.NET 改写 注册表

去年年末才看过一本关于ASP.NET 操作注册表的书,可惜那时候就压根没想过写到网上去。

现在想想 写到网上有诸多好处

比如、

1、可以快速回忆相关知识点,还有自己写的参考代码,比别人写的强多了

2、可以丰富自己的博客推广自己

3、加强自己写作能力

 

贴出代码了

--------------------

1、引入命名空间

using Microsoft.Win32;//修改注册表所需要用到的命名空间

 

 

2、之后方法喽

//修改注册表 设置IE打印背景图片 适用于IE8一下版本,修改为工具选项下的 打印背景颜色与图像
        public void IESetupPrint_Background()
        {
            RegistryKey key = Registry.CurrentUser;
            RegistryKey software = key.OpenSubKey("Software\\Microsoft\\Internet Explorer\\Main", true); //该项必须已存在

            software.SetValue("Print_Background", "yes");
            software.Close();

        }

        //设置页眉 页脚为空
        public void IESetupPageSetup()
        {
            RegistryKey key = Registry.CurrentUser;
            RegistryKey software = key.OpenSubKey("Software\\Microsoft\\Internet Explorer\\PageSetup", true); //该项必须已存在

            software.SetValue("header", "");
            software.SetValue("footer", "");
            software.Close();
        }

        //设置页边距 设置IE页面设置 打印背景图片
        //上下边距具体的值可以 先在IE里面设置再查看注册表实际值 然后在程序里写死
        public void IESetupPage()
        {
            RegistryKey key = Registry.CurrentUser;//IE8以上版本 修改为页面设置 里页面 打印背景颜色与图像
            RegistryKey software = key.OpenSubKey("Software\\Microsoft\\Internet Explorer\\PageSetup", true);

            software.SetValue("margin_top", 0.55984);
            software.SetValue("margin_bottom", 0.55984);
            software.SetValue("margin_left", 0.75433);
            software.SetValue("margin_right", 0.40000);
            software.SetValue("Print_Background", "yes");

        }

//查看注册表相应的键值 运行输入 regedit

----------------------------------------------------------

 

想要完整的代码在我资源里

http://download.csdn.net/detail/sat472291519/4316549

 

其它注册表资料

请参考书本 或参考微软官方 或 自己对照查询

更改设置方法同上

 

t_idlist
HKEY_CURRENT_USER_Software_Microsoft_Internet Explorer_TabbedBrowsing   [WarnOnClose] 0 为关 1为开 关闭多个选项卡时发出警告

 

//修改默认浏览器

private void updateRegedit()
        {
            //HKEY_CLASSES_ROOT\http\shell\open\command
            RegistryKey key = Registry.ClassesRoot;
            RegistryKey software = key.OpenSubKey("http\\shell\\open\\command", true); //该项必须已存在
            software.SetValue("", "\"C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE\" -nohome");
            software.Close();
        }

 

 

//修改 IE打开 选项卡的方式     为1时代表始终在新窗口中打开弹出窗口 为2时代表始终在新选项卡中打开弹出窗口

RegistryKey key2 = Registry.CurrentUser;
RegistryKey software2 = key2.OpenSubKey("Software\\Microsoft\\Internet Explorer\\TabbedBrowsing", true); //该项必须已存在
software2.SetValue("PopupsUseNewWindow",1);
software2.Close();

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值