附C# VB.NET互转工具:https://download.csdn/download/xxxvxxv/10877188
Imports Microsoft.Win32.Registry
Class sysProxy
''' <summary>
''' 开启代理
''' </summary>
Public Sub open()
Dim RootKey As Microsoft.Win32.RegistryKey = CurrentUser
Dim SubKey As Microsoft.Win32.RegistryKey = RootKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\", True)
SubKey.SetValue("ProxyEnable", &H1)
End Sub
''' <summary>
''' 设置代理服务器的地址跟端口
''' </summary>
''' <param name="str">如127.0.0.1:8888</param>
Public Sub setproxy(ByVal str As String)
Dim RootKey As Microsoft.Win32.RegistryKey = CurrentUser
Dim SubKey As Microsoft.Win32.RegistryKey = RootKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\", True)
SubKey.SetValue("ProxyServer", str)
SubKey.SetValue("ProxyEnable", &H1)
End Sub
''' <summary>
''' 关闭代理
''' </summary>
Public Sub close()
Dim RootKey As Microsoft.Win32.RegistryKey = CurrentUser
Dim SubKey As Microsoft.Win32.RegistryKey = RootKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\", True)
SubKey.SetValue("ProxyEnable", &H0)
End Sub
''' <summary>
''' 代理开关状态
''' </summary>
''' <param name="proxy"></param>
''' <returns></returns>
Public Function ProxyStatus(ByRef proxy As String) As Boolean
Dim RootKey As Microsoft.Win32.RegistryKey = CurrentUser
Dim SubKey As Microsoft.Win32.RegistryKey = RootKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\", True)
proxy = SubKey.GetValue("ProxyServer")
Return SubKey.GetValue("ProxyEnable")
End Function
End Class
附C# VB.NET互转工具:https://download.csdn/download/xxxvxxv/10877188
Imports Microsoft.Win32.Registry
Class sysProxy
''' <summary>
''' 开启代理
''' </summary>
Public Sub open()
Dim RootKey As Microsoft.Win32.RegistryKey = CurrentUser
Dim SubKey As Microsoft.Win32.RegistryKey = RootKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\", True)
SubKey.SetValue("ProxyEnable", &H1)
End Sub
''' <summary>
''' 设置代理服务器的地址跟端口
''' </summary>
''' <param name="str">如127.0.0.1:8888</param>
Public Sub setproxy(ByVal str As String)
Dim RootKey As Microsoft.Win32.RegistryKey = CurrentUser
Dim SubKey As Microsoft.Win32.RegistryKey = RootKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\", True)
SubKey.SetValue("ProxyServer", str)
SubKey.SetValue("ProxyEnable", &H1)
End Sub
''' <summary>
''' 关闭代理
''' </summary>
Public Sub close()
Dim RootKey As Microsoft.Win32.RegistryKey = CurrentUser
Dim SubKey As Microsoft.Win32.RegistryKey = RootKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\", True)
SubKey.SetValue("ProxyEnable", &H0)
End Sub
''' <summary>
''' 代理开关状态
''' </summary>
''' <param name="proxy"></param>
''' <returns></returns>
Public Function ProxyStatus(ByRef proxy As String) As Boolean
Dim RootKey As Microsoft.Win32.RegistryKey = CurrentUser
Dim SubKey As Microsoft.Win32.RegistryKey = RootKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings\", True)
proxy = SubKey.GetValue("ProxyServer")
Return SubKey.GetValue("ProxyEnable")
End Function
End Class