?
Solved

Set Internet Explorer proxy settings from VB.Net code

Posted on 2009-02-24
3
Medium Priority
?
2,239 Views
Last Modified: 2012-05-06
Hi Experts,

How do I turn on/off the Internet Explorer Proxy settings from my VB.Net code.
0
Comment
Question by:DColin
3 Comments
 
LVL 4

Expert Comment

by:mahadevan_v
ID: 23721521
Public Sub EnableProxy()
        If objHost.DirectConnection = False Then
            Dim regKey As RegistryKey

            regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

            regKey.SetValue("ProxyEnable", True, RegistryValueKind.DWord)
            regKey.SetValue("ProxyServer", objHost.ProxyAddress.ToString + ":" + objHost.ProxyPort.ToString, RegistryValueKind.String)

            If objHost.BypassLocal Then
                regKey.SetValue("ProxyOverride", "<local>", RegistryValueKind.String)
            Else
                regKey.DeleteValue("ProxyOverride", False)
            End If

            regKey.Close()
        Else
            MessageBox.Show("Network Switcher is currently not configured to use a proxy server. " + ControlChars.CrLf + _
                            "Please open Network Switcher settings dialog and configure the proxy server.", "Missing proxy settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If
    End Sub

    Public Sub DisableProxy()
        Dim regKey As RegistryKey

        regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

        regKey.SetValue("ProxyEnable", False, RegistryValueKind.DWord)

        regKey.Close()
    End Sub

RESTART THE IE Instance :)
0
 

Author Comment

by:DColin
ID: 23729446
Hi mahadevan_v

When I use your code I get an 'objHost not declared' error. I notice from your code that you do not declare the objHost object. Do I need to import a namespace?
0
 
LVL 4

Accepted Solution

by:
Ledigimate earned 2000 total points
ID: 23745656
It's really hard to tell, and I doubt Mahadevan_v would know because he copied the code from Neowin Forums.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question