Results 1 to 2 of 2

Thread: proxy

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Posts
    114
    Does anyone know how to set up proxy setting when using the winsock control? I have an ftp program and I want to give them the option to set this if needed.

    thanks

  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    Code:
    Private Const HKEY_CURRENT_USER = &H80000001
    Private Const REG_SZ = 1
    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, lpData As Any, 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
    
    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, ByVal strdata, Len(strdata))
        r = RegCloseKey(keyhand)
    End Sub
    
    'To enable the proxy
    Call savestring(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", 1)
    
    'to set the proxy to whatever the user specifies
    'Text1 is the proxy ip and texy2 is the port
    Dim proxy As String
    proxy = Text1.Text & ":" & Text2.TExt
    'Set the proxy
    Call savestring(HKEY_CURRENT_USER, "\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyServer", proxy)
    
    'Do the rest of your code here.
    That's the way you would go about setting a user specified proxy.

    Gl,
    D!m
    Dim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width