locked
show IE proxy settings and whether it is enabled or not RRS feed

  • Question

  • Hi

    Does anyone know how I can show the proxy setting for IE in my vb.net app - want to show if enabled/disabled, and if enabled what settings it is using

    Thanks


    Darren Rose

    Monday, December 30, 2013 8:44 PM

Answers

  • Hi,

    Welcome to MSDN.

    Hefin Dsouza has shared a class in this link as following one:

    Imports Microsoft.Win32
    Public Class ProxySetting
        Public Function IsProxyEnabled() As Boolean
            Try
                Dim Regs As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", RegistryKeyPermissionCheck.ReadWriteSubTree)
                If Regs.GetValue("ProxyEnable") <> Nothing Then
                    If Regs.GetValue("ProxyEnable").ToString() = "0" Then
                        Return False
                    Else
                        Return True
                    End If
                Else
                    Return False
                End If
            Catch ex As Exception
                Return False
            End Try
        End Function
    
        Public Function GetProxyServer() As String
            Try
                Dim Regs As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", RegistryKeyPermissionCheck.ReadWriteSubTree)
                If Regs.GetValue("ProxyServer") <> Nothing Then
                    Return Regs.GetValue("ProxyServer").ToString()
                Else
                    Return ""
                End If
            Catch ex As Exception
                Return ""
            End Try
        End Function
    
        Public Sub DisableProxy()
            Dim regKey As RegistryKey
            Try
                regKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
                regKey.SetValue("ProxyEnable", False, RegistryValueKind.DWord)
                regKey.Close()
            Catch ex As Exception
    
            End Try
        End Sub
    
        Public Sub SetProxy(ByVal ServerName As String, ByVal port As Integer)
            Try
                Dim regkey1 As RegistryKey
                regkey1 = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
                regkey1.SetValue("ProxyServer", ServerName + ":" + port.ToString(), RegistryValueKind.Unknown)
                regkey1.SetValue("ProxyEnable", True, RegistryValueKind.DWord)
                regkey1.Close()
            Catch ex As Exception
    
            End Try
        End Sub
    
    End Class

     

    How to use the class and its methods
    1) To Check Whether Proxy Is Enabled or Disabled call the Function IsProxyEnabled()
    Example :

    Dim Proxy as new ProxySetting()
    If pxy.IsProxyEnabled() Then
    Msgbox("Proxy Enabled")
    End If

    2) Set IE Proxy you need to call the SetProxy() method which takes 2 Parameters the first the IP or the Host Name and the second the Port Number.
    Example

    Proxy.SetProxy(TxtProxy.Text, Convert.ToInt16(txtPort.Text))


    3) Disable Proxy Settings you need to call the Method DisableProxy()

    Proxy.DisableProxy()

    4) To get what proxy is already applied you need to call the Function GetProxyServer();

    Dim ServerAndProxy() As String = Proxy.GetProxyServer().Split(":")
    TxtProxy.Text = ServerAndProxy(0)
    txtPort.Text = ServerAndProxy(1)

    In the code above i split the Result of GetProxyServer() with the seperator : to get the Host and the IP seperately.

     

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Carl Cai Wednesday, January 1, 2014 1:36 AM
    • Marked as answer by wingers Wednesday, January 1, 2014 2:06 AM
    Tuesday, December 31, 2013 8:50 AM
  • thank you very much - very helpful indeed

    Code all working fine for me - except the disable proxy part - which doesn't seem to disable it


    Darren Rose

    If you logoff and log back on or reboot is it disabled? Perhaps that is required in order for the registry settings to take effect.

    I used the Pinvoke code in this thread to notify the shell that file extensions have been changed for registry entries. It works for that.

    I found this link How to refresh explorer after a registry change and these links from Pinvoke.Net for notifying the shell of events also shchangenotify (shell32) , SHCNE (Enums) and this link from Microsoft MSDN SHChangeNotify function . Maybe one of those will work for you in some fashion.


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.

    • Proposed as answer by Carl Cai Wednesday, January 1, 2014 1:36 AM
    • Marked as answer by Carl Cai Tuesday, January 7, 2014 10:10 AM
    Tuesday, December 31, 2013 2:47 PM
  • Hi,

    Sorry for that I tested that code, it didn't work for me.

    Then I tested it with the following code, it worked fine, you could have a try:

     Dim regKey As RegistryKey = My.Computer.Registry.CurrentUser
            Dim subKey As Microsoft.Win32.RegistryKey = regKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
            Try         
                subKey.SetValue("ProxyEnable", 0, RegistryValueKind.DWord)
                subKey.Close()
            Catch ex As Exception
                MsgBox(ex.ToString())
            End Try

    Regards.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Thanks for reply

    I got it working, by changing code to:-

    Try
       My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", 0)
    Catch ex As Exception
    
    End Try
    This seems to work, but obviously doesn't take effect until after reboot - but that is not a problem anyway


    Darren Rose

    • Marked as answer by Carl Cai Tuesday, January 7, 2014 10:10 AM
    Thursday, January 2, 2014 1:14 PM

All replies

  • Hi Darren,

    Since it is related to VB, I am moving your thread into the Visual Basic Forum for better response. Thanks for your understanding.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 31, 2013 8:25 AM
  • Hi,

    Welcome to MSDN.

    Hefin Dsouza has shared a class in this link as following one:

    Imports Microsoft.Win32
    Public Class ProxySetting
        Public Function IsProxyEnabled() As Boolean
            Try
                Dim Regs As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", RegistryKeyPermissionCheck.ReadWriteSubTree)
                If Regs.GetValue("ProxyEnable") <> Nothing Then
                    If Regs.GetValue("ProxyEnable").ToString() = "0" Then
                        Return False
                    Else
                        Return True
                    End If
                Else
                    Return False
                End If
            Catch ex As Exception
                Return False
            End Try
        End Function
    
        Public Function GetProxyServer() As String
            Try
                Dim Regs As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", RegistryKeyPermissionCheck.ReadWriteSubTree)
                If Regs.GetValue("ProxyServer") <> Nothing Then
                    Return Regs.GetValue("ProxyServer").ToString()
                Else
                    Return ""
                End If
            Catch ex As Exception
                Return ""
            End Try
        End Function
    
        Public Sub DisableProxy()
            Dim regKey As RegistryKey
            Try
                regKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
                regKey.SetValue("ProxyEnable", False, RegistryValueKind.DWord)
                regKey.Close()
            Catch ex As Exception
    
            End Try
        End Sub
    
        Public Sub SetProxy(ByVal ServerName As String, ByVal port As Integer)
            Try
                Dim regkey1 As RegistryKey
                regkey1 = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
                regkey1.SetValue("ProxyServer", ServerName + ":" + port.ToString(), RegistryValueKind.Unknown)
                regkey1.SetValue("ProxyEnable", True, RegistryValueKind.DWord)
                regkey1.Close()
            Catch ex As Exception
    
            End Try
        End Sub
    
    End Class

     

    How to use the class and its methods
    1) To Check Whether Proxy Is Enabled or Disabled call the Function IsProxyEnabled()
    Example :

    Dim Proxy as new ProxySetting()
    If pxy.IsProxyEnabled() Then
    Msgbox("Proxy Enabled")
    End If

    2) Set IE Proxy you need to call the SetProxy() method which takes 2 Parameters the first the IP or the Host Name and the second the Port Number.
    Example

    Proxy.SetProxy(TxtProxy.Text, Convert.ToInt16(txtPort.Text))


    3) Disable Proxy Settings you need to call the Method DisableProxy()

    Proxy.DisableProxy()

    4) To get what proxy is already applied you need to call the Function GetProxyServer();

    Dim ServerAndProxy() As String = Proxy.GetProxyServer().Split(":")
    TxtProxy.Text = ServerAndProxy(0)
    txtPort.Text = ServerAndProxy(1)

    In the code above i split the Result of GetProxyServer() with the seperator : to get the Host and the IP seperately.

     

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Carl Cai Wednesday, January 1, 2014 1:36 AM
    • Marked as answer by wingers Wednesday, January 1, 2014 2:06 AM
    Tuesday, December 31, 2013 8:50 AM
  • thank you very much - very helpful indeed

    Code all working fine for me - except the disable proxy part - which doesn't seem to disable it


    Darren Rose

    Tuesday, December 31, 2013 2:17 PM
  • thank you very much - very helpful indeed

    Code all working fine for me - except the disable proxy part - which doesn't seem to disable it


    Darren Rose

    If you logoff and log back on or reboot is it disabled? Perhaps that is required in order for the registry settings to take effect.

    I used the Pinvoke code in this thread to notify the shell that file extensions have been changed for registry entries. It works for that.

    I found this link How to refresh explorer after a registry change and these links from Pinvoke.Net for notifying the shell of events also shchangenotify (shell32) , SHCNE (Enums) and this link from Microsoft MSDN SHChangeNotify function . Maybe one of those will work for you in some fashion.


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.

    • Proposed as answer by Carl Cai Wednesday, January 1, 2014 1:36 AM
    • Marked as answer by Carl Cai Tuesday, January 7, 2014 10:10 AM
    Tuesday, December 31, 2013 2:47 PM
  • Hi,

    Happy new year!

    Mr. Monkeyboy has shared how to check the effect of changing registry settings.

    In addition, if your OS is 64 bit, I suggest you change the platform to x64 with these steps :

    "Build->Configuration Manager" then change it as following image:

    And run that project as admin.

    Then try to check that effect as the way Mr. Monkeyboy shared.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 1, 2014 5:47 AM
  • Problem was that it needed to reboot after changing the registry value before it worked

    Tried suggestions to get it to notice change immediately , but couldn't understand or get the code to work

    Finished program will need to run on 32 and 64 bit so haven't changed platform to x64 - as I assume if I do it won't work on x86 then

    Happy New Year!


    Darren Rose


    • Edited by wingers Wednesday, January 1, 2014 12:56 PM
    Wednesday, January 1, 2014 12:56 PM
  • Problem was that it needed to reboot after changing the registry value before it worked

    Tried suggestions to get it to notice change immediately , but couldn't understand or get the code to work

    Finished program will need to run on 32 and 64 bit so haven't changed platform to x64 - as I assume if I do it won't work on x86 then

    Happy New Year!


    Darren Rose


    Perhaps you should use a search engine to attempt to figure out what you are attempting to do. Instead of giving up because the answer wasn't handed to you on a silver platter.

    This code looks like it will work if you configure it accurately.

    Option Strict On
    
    Imports Microsoft.Win32
    Imports System.Runtime.InteropServices
    
    Public Class Form1
    
        <DllImport("shell32.dll")> _
        Shared Sub SHChangeNotify( _
         ByVal wEventID As HChangeNotifyEventID, _
         ByVal uFlags As HChangeNotifyFlags, _
         ByVal dwItem1 As IntPtr, _
         ByVal dwItem2 As IntPtr)
        End Sub
    
        <Flags()> _
        Public Enum HChangeNotifyEventID
            ' <summary>
            ' All events have occurred. 
            ' </summary>
            SHCNE_ALLEVENTS = &H7FFFFFFF
    
            ' <summary>
            ' A file type association has changed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> 
            ' must be specified in the <i>uFlags</i> parameter. 
            ' <i>dwItem1</i> and <i>dwItem2</i> are not used and must be <see langword="null"/>. 
            ' </summary>
            SHCNE_ASSOCCHANGED = &H8000000
    
            ' <summary>
            ' The attributes of an item or folder have changed. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the item or folder that has changed. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>.
            ' </summary>
            SHCNE_ATTRIBUTES = &H800
    
            ' <summary>
            ' A nonfolder item has been created. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the item that was created. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>.
            ' </summary>
            SHCNE_CREATE = &H2
    
            ' <summary>
            ' A nonfolder item has been deleted. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the item that was deleted. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_DELETE = &H4
    
            ' <summary>
            ' A drive has been added. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the root of the drive that was added. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_DRIVEADD = &H100
    
            ' <summary>
            ' A drive has been added and the Shell should create a new window for the drive. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the root of the drive that was added. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_DRIVEADDGUI = &H10000
    
            ' <summary>
            ' A drive has been removed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the root of the drive that was removed.
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_DRIVEREMOVED = &H80
    
            ' <summary>
            ' Not currently used. 
            ' </summary>
            SHCNE_EXTENDED_EVENT = &H4000000
    
            ' <summary>
            ' The amount of free space on a drive has changed. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the root of the drive on which the free space changed.
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_FREESPACE = &H40000
    
            ' <summary>
            ' Storage media has been inserted into a drive. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the root of the drive that contains the new media. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_MEDIAINSERTED = &H20
    
            ' <summary>
            ' Storage media has been removed from a drive. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the root of the drive from which the media was removed. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_MEDIAREMOVED = &H40
    
            ' <summary>
            ' A folder has been created. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> 
            ' or <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the folder that was created. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_MKDIR = &H8
    
            ' <summary>
            ' A folder on the local computer is being shared via the network. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the folder that is being shared. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_NETSHARE = &H200
    
            ' <summary>
            ' A folder on the local computer is no longer being shared via the network. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the folder that is no longer being shared. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_NETUNSHARE = &H400
    
            ' <summary>
            ' The name of a folder has changed. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the previous pointer to an item identifier list (PIDL) or name of the folder. 
            ' <i>dwItem2</i> contains the new PIDL or name of the folder. 
            ' </summary>
            SHCNE_RENAMEFOLDER = &H20000
    
            ' <summary>
            ' The name of a nonfolder item has changed. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the previous PIDL or name of the item. 
            ' <i>dwItem2</i> contains the new PIDL or name of the item. 
            ' </summary>
            SHCNE_RENAMEITEM = &H1
    
            ' <summary>
            ' A folder has been removed. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the folder that was removed. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_RMDIR = &H10
    
            ' <summary>
            ' The computer has disconnected from a server. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the server from which the computer was disconnected. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' </summary>
            SHCNE_SERVERDISCONNECT = &H4000
    
            ' <summary>
            ' The contents of an existing folder have changed 
            ' but the folder still exists and has not been renamed. 
            ' <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
            ' <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
            ' <i>dwItem1</i> contains the folder that has changed. 
            ' <i>dwItem2</i> is not used and should be <see langword="null"/>. 
            ' If a folder has been created deleted or renamed use SHCNE_MKDIR SHCNE_RMDIR or 
            ' SHCNE_RENAMEFOLDER respectively instead. 
            ' </summary>
            SHCNE_UPDATEDIR = &H1000
    
            ' <summary>
            ' An image in the system image list has changed. 
            ' <see cref="HChangeNotifyFlags.SHCNF_DWORD"/> must be specified in <i>uFlags</i>. 
            ' </summary>
            SHCNE_UPDATEIMAGE = &H8000
        End Enum
    
        <Flags()> _
        Public Enum HChangeNotifyFlags
            ' <summary>
            ' The <i>dwItem1</i> and <i>dwItem2</i> parameters are DWORD values. 
            ' </summary>
            SHCNF_DWORD = &H3
            ' <summary>
            ' <i>dwItem1</i> and <i>dwItem2</i> are the addresses of ITEMIDLIST structures that 
            ' represent the item(s) affected by the change. 
            ' Each ITEMIDLIST must be relative to the desktop folder. 
            ' </summary>
            SHCNF_IDLIST = &H0
            ' <summary>
            ' <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of 
            ' maximum length MAX_PATH that contain the full path names 
            ' of the items affected by the change. 
            ' </summary>
            SHCNF_PATHA = &H1
            ' <summary>
            ' <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of 
            ' maximum length MAX_PATH that contain the full path names 
            ' of the items affected by the change. 
            ' </summary>
            SHCNF_PATHW = &H5
            ' <summary>
            ' <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that 
            ' represent the friendly names of the printer(s) affected by the change. 
            ' </summary>
            SHCNF_PRINTERA = &H2
            ' <summary>
            ' <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that 
            ' represent the friendly names of the printer(s) affected by the change. 
            ' </summary>
            SHCNF_PRINTERW = &H6
            ' <summary>
            ' The function should not return until the notification 
            ' has been delivered to all affected components. 
            ' As this flag modifies other data-type flags it cannot by used by itself.
            ' </summary>
            SHCNF_FLUSH = &H1000
            ' <summary>
            ' The function should begin delivering notifications to all affected components 
            ' but should return as soon as the notification process has begun. 
            ' As this flag modifies other data-type flags it cannot by used by itself.
            ' </summary>
            SHCNF_FLUSHNOWAIT = &H2000
        End Enum
    
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        End Sub
    
    
        Private Sub SetFileAssociation( _
    ByVal FileExt As String, _
    ByVal FileClass As String, _
    ByVal Description As String, _
    ByVal Icon As String, _
    ByVal Verb As String, _
    ByVal VerbDescription As String, _
    ByVal Command As String _
    )
    
            Dim RegKey As RegistryKey = Registry.ClassesRoot.CreateSubKey("." + FileExt)
            RegKey.SetValue("", FileClass)
    
            Dim RegKeyClass = Registry.ClassesRoot.CreateSubKey(FileClass)
            RegKeyClass.SetValue("", Description)
            If (Not Icon Is Nothing) Then
                RegKey = RegKeyClass.CreateSubKey("DefaultIcon")
                'RegistryValueKind is only supported on CLR 2.0
                'RegKey.SetValue("", Icon, RegistryValueKind.ExpandString)
                RegKey.SetValue("", Icon)
            End If
    
            RegKey = RegKeyClass.CreateSubKey("shell")
            RegKey = RegKeyClass.CreateSubKey("shell\" + Verb)
            If (Not VerbDescription Is Nothing) Then
                RegKey.SetValue("", VerbDescription)
            End If
            RegKey = RegKeyClass.CreateSubKey("shell\" + Verb + "\command")
            RegKey.SetValue("", Command)
    
            SHChangeNotify(HChangeNotifyEventID.SHCNE_ASSOCCHANGED, HChangeNotifyFlags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero)
        End Sub
    
    
    End Class
    


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.

    Wednesday, January 1, 2014 3:46 PM
  • @ Mr. Monkeyboy

    Didn't say I was giving up - and didn't ask for it on a silver platter!

    Have been googling and trying things since I posted earlier, as I always do when trying to solve a problem


    Darren Rose

    Wednesday, January 1, 2014 3:53 PM
  • Hi,

    Sorry for that I tested that code, it didn't work for me.

    Then I tested it with the following code, it worked fine, you could have a try:

     Dim regKey As RegistryKey = My.Computer.Registry.CurrentUser
            Dim subKey As Microsoft.Win32.RegistryKey = regKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
            Try         
                subKey.SetValue("ProxyEnable", 0, RegistryValueKind.DWord)
                subKey.Close()
            Catch ex As Exception
                MsgBox(ex.ToString())
            End Try

    Regards.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Carl Cai Thursday, January 2, 2014 5:49 AM
    Thursday, January 2, 2014 5:48 AM
  • Hi,

    Sorry for that I tested that code, it didn't work for me.

    Then I tested it with the following code, it worked fine, you could have a try:

     Dim regKey As RegistryKey = My.Computer.Registry.CurrentUser
            Dim subKey As Microsoft.Win32.RegistryKey = regKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
            Try         
                subKey.SetValue("ProxyEnable", 0, RegistryValueKind.DWord)
                subKey.Close()
            Catch ex As Exception
                MsgBox(ex.ToString())
            End Try

    Regards.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Thanks for reply

    I got it working, by changing code to:-

    Try
       My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", 0)
    Catch ex As Exception
    
    End Try
    This seems to work, but obviously doesn't take effect until after reboot - but that is not a problem anyway


    Darren Rose

    • Marked as answer by Carl Cai Tuesday, January 7, 2014 10:10 AM
    Thursday, January 2, 2014 1:14 PM