Private Const HKEY_CURRENT_USER = &H80000001
Private Const REG_SZ = 1
Private Const REG_SZ1 = 0
Private Const REG_BINARY = 3
Private Const REG_DWORD = 4
Private Const ERROR_SUCCESS = 0&
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" _
Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey _
As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal
Hkey As Long) As Long
'this function enables the proxy and the value i have hardcoded
Private Sub Command1_Click()
proxy = "1.1.1.1:80"
Dim WshShell As Object
Set WshShell = CreateObject("WScript.Shell")
Call savestring(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", 1)
'Call savestring(HKEY_CURRENT_USER, "\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer", proxy)
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer", "1.1.1.1:80", "REG_SZ"
Form1.Label1.Visible = True
Form1.Label2.Visible = True
Form1.Label3.Caption = "The Proxy Is Enabled On This Machine"
'MsgBox ("Enabled")
End Sub
'this function disables the proxy (it has a problem i guess)
Private Sub Command2_Click()
Dim WshShell As Object
Set WshShell = CreateObject("WScript.Shell")
Call savestring(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", 0)
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer", "", "REG_SZ"
'MsgBox ("Disabled")
Form1.Label1.Visible = False
Form1.Label2.Visible = False
Form1.Label3.Caption = "The Proxy Is Disabled On This Machine"
End Sub
'just to exit
Private Sub Command3_Click()
End
End Sub
'the form load function
Private Sub Form_Load()
Form1.Label1.Visible = False
Form1.Label2.Visible = False
Form1.Label3.Caption = "Please Click To Enable Or Disable The Proxy"
End Sub
'this function is called from above to enable/disable proxy Setting
Public Sub savestring(Hkey As Long, strPath As String, strValue As String, strdata As String)
On Error Resume Next
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(Hkey, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, strdata, Len(strdata))
r = RegCloseKey(keyhand)
End Sub