Home | What's New | Articles | Code Downloads | Tool Box | Links | Code Snippets  

Internet

Connecting to the Internet

This code shows you how to use functions of "wininet.dll" to connect and disconnect from the Internet.  For these functions to work Internet Explorer 4.0 or greater  must be installed.

Place this in the General Declarations section of a form

Private Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Const INTERNET_AUTODIAL_FORCE_ONLINE = 1
Private Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2

Private Declare Function InternetAutodialHangup Lib "wininet.dll" (ByVal dwReserved As Long) As Long

To prompt the user to connect to the Internet use:

If InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0) Then
    MsgBox "Connected"
End If

To display the "Dial-up Connection" window and automatically start dialing use:

If InternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED, 0) Then
    MsgBox "Connected"
End If

To disconnect an automatically dial Internet connection use:

If InternetAutodialHangup(0) Then
   MsgBox "Disconnected"
End If