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.

derossAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KhollADCommented:
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

Private Type RASCONNSTATUS95
  '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
Dim Tstatus As RASCONNSTATUS95

  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
  Else
    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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.