Я хотел бы знать, как мне добавить proxy username and proxy password
к моему Form1
, чтобы иметь возможность изменить свой прокси в глобальных настройках windows. На данный момент он работает, но только в формате Proxy IP : Proxy port
Мой провайдер прокси предоставил мне только прокси
Imports System.IO
Imports System.Net
Public Class Form1
Private Sub btnconnect_Click(sender As Object, e As EventArgs) Handles btnConnectDisconnect.Click
Dim clsProxy As New IEProxy
If My.Settings.IEProxyConnected Then
If clsProxy.DisableProxy Then
btnConnectDisconnect.Text = "Connect"
My.Settings.IEProxyConnected = False
MessageBox.Show("Proxy successfully disabled.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Error disabling proxy.", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
Else
If Not (String.IsNullOrEmpty(txtIP.Text) Or String.IsNullOrEmpty(txtPort.Text)) Then
Dim port As Integer
Dim proxyIP_user As String = txtUser.Text
Dim proxyIP_pass As String = txtPass.Text
If Integer.TryParse(txtPort.Text, port) Then
Dim p As WebProxy = New WebProxy(txtIP.Text.Trim, port)
Dim credentials As ICredentials = New NetworkCredential(proxyIP_user, proxyIP_pass)
My.Settings.RootProxy = p
My.Settings.Save()
Dim x As WebProxy = New WebProxy(txtIP.Text, True, Nothing, credentials)
If clsProxy.SetProxy(p.Address.Host & ":" & p.Address.Port) Then
btnConnectDisconnect.Text = "Disconnect"
My.Settings.IEProxyConnected = True
MessageBox.Show("Proxy successfully enabled.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Error enabling proxy.", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End If
Else
MessageBox.Show("Please enter the proxy bought from StormProxy.com", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End If
My.Settings.Save()
End Sub
End Class