C#修改注册表(IE),
2008-03-11 11:45
483 查看
C#修改注册表(IE),以修改IE代理服务器为例:
using System;
using System.Collections;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using Microsoft.Win32;
namespace TestBlog
{
class Program
{
[DllImport(@"wininet",
SetLastError = true,
CharSet = CharSet.Auto,
EntryPoint = "InternetSetOption",
CallingConvention = CallingConvention.StdCall)]
public static extern bool InternetSetOption
(
int hInternet,
int dmOption,
IntPtr lpBuffer,
int dwBufferLength
);
public static void SetProxy(string proxy)
{
//打开注册表
RegistryKey regKey = Registry.CurrentUser;
string SubKeyPath = @"Software/Microsoft/Windows/CurrentVersion/Internet Settings";
RegistryKey optionKey = regKey.OpenSubKey(SubKeyPath, true);
//更改健值,设置代理,
optionKey.SetValue("ProxyEnable", 1);
optionKey.SetValue("ProxyServer", proxy);
//激活代理设置
InternetSetOption(0, 39, IntPtr.Zero, 0);
InternetSetOption(0, 37, IntPtr.Zero, 0);
}
}
文章引用自:
using System;
using System.Collections;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using Microsoft.Win32;
namespace TestBlog
{
class Program
{
[DllImport(@"wininet",
SetLastError = true,
CharSet = CharSet.Auto,
EntryPoint = "InternetSetOption",
CallingConvention = CallingConvention.StdCall)]
public static extern bool InternetSetOption
(
int hInternet,
int dmOption,
IntPtr lpBuffer,
int dwBufferLength
);
public static void SetProxy(string proxy)
{
//打开注册表
RegistryKey regKey = Registry.CurrentUser;
string SubKeyPath = @"Software/Microsoft/Windows/CurrentVersion/Internet Settings";
RegistryKey optionKey = regKey.OpenSubKey(SubKeyPath, true);
//更改健值,设置代理,
optionKey.SetValue("ProxyEnable", 1);
optionKey.SetValue("ProxyServer", proxy);
//激活代理设置
InternetSetOption(0, 39, IntPtr.Zero, 0);
InternetSetOption(0, 37, IntPtr.Zero, 0);
}
}
文章引用自:
相关文章推荐
- C#调用注册表,修改IE相关配置
- c#修改注册表(修改IE主页)
- js、c#修改ie设置,针对注册表的修改
- 用c#语言通过修改注册表改IE网页首页
- C#修改注册表 以修改IE代理服务器
- C#通过修改注册表改变IE默认选项
- 修改注册表,实现屏蔽IE右键功能
- bingil C#利用注册表获取及修改不同网上的IP地址 lanix
- VBS 通过注册表修改ie的安全级别,允许本地文件的脚本运行
- 【Win7中如何通过修改注册表将IE设置为默认浏览器】
- 通过修改注册表让IE实现多线程下载
- C#设置注册表权限失败,修改应用程序以管理员身份执行
- C#综合揭秘——通过修改注册表建立Windows自定义协议
- C# 使注册表修改后立即生效
- 【转】C#综合揭秘——通过修改注册表建立Windows自定义协议
- 用注册表修改被改的IE的主页
- 一种通过注册表简便修改IE代理服务器的方法
- C#修改注册表
- c# 注册表修改
- C#修改注册表