去年年末才看过一本关于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();