Know when internet is fully logged in

As part of my program, I have an option to download FTP reports from the internet.  I know how to connect.  My problem is, how do I know when to issue the FTP commands.  (I do not want to issue them until fully logged into the internet.

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

KhollADConnect With a Mentor Commented:
You can use the Ras Api features to test if the user is fully logged into internet :

Private Const RAS95_MaxEntryName = 256
Private Const RAS_MaxDeviceType = 16
Private Const RAS95_MaxDeviceName = 128
Private Const RASCS_DONE = &H2000&

Private Type RASCONN95
  'set dwsize to 412
  dwSize As Long
  hRasConn As Long
  szEntryName(RAS95_MaxEntryName) As Byte
  szDeviceType(RAS_MaxDeviceType) As Byte
  szDeviceName(RAS95_MaxDeviceName) As Byte
End Type

  'set dwsize to 160
  dwSize As Long
  RasConnState As Long
  dwError As Long
  szDeviceType(RAS_MaxDeviceType) As Byte
  szDeviceName(RAS95_MaxDeviceName) As Byte
End Type

Private Declare Function RasEnumConnections Lib "RasApi32.dll" Alias "RasEnumConnectionsA" (lprasconn As Any, lpcb As Long, lpcConnections As Long) As Long
Private Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias "RasGetConnectStatusA" (ByVal hRasConn As Long, lpRASCONNSTATUS As Any) As Long

Private Function IsRASConnected() As Boolean

IsRASConnected = False

Dim TRasCon(255) As RASCONN95
Dim lg As Long
Dim lpcon As Long
Dim lReturn As Long

  TRasCon(0).dwSize = 412
  lg = 256 * TRasCon(0).dwSize
  lReturn = RasEnumConnections(TRasCon(0), lg, lpcon)
  If lReturn <> 0 Then
    Exit Function
  End If

  Tstatus.dwSize = 160
  lReturn = RasGetConnectStatus(TRasCon(0).hRasConn, Tstatus)
  If Tstatus.RasConnState = RASCS_DONE Then
    IsRASConnected = True
    IsRASConnected = False
  End If
End Function

Private Sub Command1_Click()

    Dim Connected As Boolean
    Connected = IsRASConnected
    MsgBox IIf(Connected, "Logged On Internet", "Not Logged On Internet")
End Sub
All Courses

From novice to tech pro — start learning today.