[.NET] Windows系统全局代理IP设置

附C# VB.NET互转工具:https:download.csdndownloadxxxvxxv10877188 Imports Microsoft.Win32.RegistryClass sysProx

附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


发布者:admin,转转请注明出处:http://www.yc00.com/web/1734803793a3759063.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信