Registry and IE proxy

Z

Zürcher See

I'm trying to set a value in the registry in order to configure IE so that
it uses a proxy

I found out that there are two values:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings\ProxyEnabled
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet
Settings\ProxyServer

ProxyEnabled is a switch 0/1
ProxyServer contains the proxy IP or proxy URL

But when I try to write in the registry I have the following error:

Into the registry key cannot be written.
at Microsoft.Win32.RegistryKey.ValidateState(Boolean needWrite)
at Microsoft.Win32.RegistryKey.SetValue(String name, Object value)


Microsoft.Win32.RegistryKey regKey =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows
\CurrentVersion\Internet Settings");
regKey.SetValue("ProxyEnabled",1);
regKey.SetValue("ProxyServer",sProxy);
 
Z

Zürcher See

I found the problem

so is readonly
Microsoft.Win32.RegistryKey regKey
=Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Window
s\CurrentVersion\Internet Settings");

so is read-write
Microsoft.Win32.RegistryKey regKey
=Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Window
s\CurrentVersion\Internet Settings",true);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top