Results 1 to 2 of 2

Thread: create Internet connection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Egypt
    Posts
    179

    create Internet connection

    Hello,

    Any one have ready made code for creating internet connection.

    Thanks

  2. #2
    Member
    Join Date
    Sep 2001
    Location
    Australia
    Posts
    36
    Something like this ? This connects to an FTP server...

    VB Code:
    1. Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    2. Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, _
    3.                 ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, _
    4.                 ByVal lFlags As Long) As Long
    5.  
    6. Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession _
    7.                 As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, _
    8.                 ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) _
    9.                 As Long
    10. Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
    11.  
    12.  
    13. Ret = GetSystemDirectory(FTPDir, 255)
    14.     FTPDir = Left$(FTPDir, Ret)
    15.     If Ret > 0 Then
    16.         FTPDir = FTPDir & "\FTP.exe"
    17.     Else
    18.         MsgBox "Error in FTP..... exiting!"
    19.         Exit Sub
    20.     End If
    21. 'Open our connection
    22.     IOpen = InternetOpen(FTPDir, 0, vbNullString, vbNullString, 0)
    23.     IConnect = InternetConnect(IOpen, Me.txtAddress, 21, Me.txtUser, Me.txtPassword, 1, INTERNET_FLAG_PASSIVE, 0)
    24.     If IOpen = 0 Or IConnect = 0 Then
    25.         MsgBox "Could not open connection to : " & Me.txtAddress
    26.         InternetCloseHandle IConnect
    27.         InternetCloseHandle IOpen
    28.         Exit Sub
    29.     End If

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