Advanced: CHECK for Internet Connection 
Author Message
 Advanced: CHECK for Internet Connection

Hi,

I've posted this question once before, but there was nobody who could
give the right answer.
Here is the question (using VB 5.0 or VC++ (latest version: 5?):

"How do you CHECK whether the user is logged on to the Internet ?"
(in a DOS or Win95 (<-- preffered) program)

My program needs to check (without the user sees anything) for an
Internet Connection, so if there is, it can send some info over the
Internet.
But when I try to check for an connection (using the Inet control) there
pops up the 'Connect To' window (the one where you have to enter your
user name, password and phone-number and then press 'Connect')

On my computer that screen also appears when I start Netscape, FTP and
Explorer.

Please, anyone who knows the answer....... Please tell me...

Thanks,

        JB



Thu, 06 Jul 2000 03:00:00 GMT  
 Advanced: CHECK for Internet Connection

Again here is the code:
Option Explicit
'     '

Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias
"RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections
As Long) As Long

Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias
"RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As
Long
       '     '
       Public Const RAS95_MaxEntryName = 256
       Public Const RAS95_MaxDeviceType = 16
       Public Const RAS95_MaxDeviceName = 32
       '     '

Public Type RASCONN95
       dwSize As Long
       hRasCon As Long
       szEntryName(RAS95_MaxEntryName) As Byte
       szDeviceType(RAS95_MaxDeviceType) As Byte
       szDeviceName(RAS95_MaxDeviceName) As Byte
End Type

'     '

Public Type RASCONNSTATUS95
       dwSize As Long
       RasConnState As Long
       dwError As Long
       szDeviceType(RAS95_MaxDeviceType) As Byte
       szDeviceName(RAS95_MaxDeviceName) As Byte
End Type

'****************************************************************************
'************************
' Name: IsConnected
'Description:The function IsConnected test if another application has
'connected
'     sucessfull
'to Internet.
'By: DELEAU Jean-Marie
'
'     'Inputs:None
'     'Returns:IsConnected return True (boolean) if the connection is
'succesful.
'     'Assumes:The function works in WIN95 (Not in NT)
'     'Side Effects:None
'
'Code provided by Planet Source Code(tm) 'as is', without
'     warranties as to performance, fitness, merchantability,
'     and any other warranty (whether expressed or implied).
'****************************************************************************
'************************

Public Function IsConnected() As Boolean

       '     '
       Dim TRasCon(255) As RASCONN95
       Dim lg As Long
       Dim lpcon As Long
       Dim RetVal As Long
       Dim Tstatus As RASCONNSTATUS95
       '     '
       TRasCon(0).dwSize = 412

       lg = 256 * TRasCon(0).dwSize
       '     '
       RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
       If lpcon = 0 Then
       MsgBox "Not connected"
       Exit Function
End If

'for test
MsgBox ByteToString(TRasCon(0).szEntryName)

'
'     '
Tstatus.dwSize = 160
RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
If Tstatus.RasConnState = &H2000 Then
 IsConnected = True
 Else
 IsConnected = False
 End If
End Function
Public Function ByteToString(bytString() As Byte) As String
'create temp work string
Dim tStr As String
'make the work string the same length as the byte array
tStr = Space$(UBound(bytString()) - LBound(bytString()))
Dim i As Integer
    i = 0
   ' loop through the array replacing characters
    While bytString(i) <> 0&
      Mid(tStr, i + 1, 1) = Chr(bytString(i))
       i = i + 1
    Wend
'trim the string down to length
ByteToString = Left(tStr, i)

End Function

Quote:

>Hi,

>I've posted this question once before, but there was nobody who could
>give the right answer.
>Here is the question (using VB 5.0 or VC++ (latest version: 5?):

>"How do you CHECK whether the user is logged on to the Internet ?"
>(in a DOS or Win95 (<-- preffered) program)

>My program needs to check (without the user sees anything) for an
>Internet Connection, so if there is, it can send some info over the
>Internet.
>But when I try to check for an connection (using the Inet control) there
>pops up the 'Connect To' window (the one where you have to enter your
>user name, password and phone-number and then press 'Connect')

>On my computer that screen also appears when I start Netscape, FTP and
>Explorer.

>Please, anyone who knows the answer....... Please tell me...

>Thanks,

>    JB



Fri, 07 Jul 2000 03:00:00 GMT  
 Advanced: CHECK for Internet Connection

I don't know the answer to your question off the top of my head but the MFC
wininet stuff comes with source code if you have VC++. It should be pretty
easy to modify the class to do what you want.  Another option would be to
use Win32 API as it would allow you to program at a lower level and not get
some of the 'automatic' functionality that you get with MFC.

Quote:

>Hi,

>I've posted this question once before, but there was nobody who could
>give the right answer.
>Here is the question (using VB 5.0 or VC++ (latest version: 5?):

>"How do you CHECK whether the user is logged on to the Internet ?"
>(in a DOS or Win95 (<-- preffered) program)

>My program needs to check (without the user sees anything) for an
>Internet Connection, so if there is, it can send some info over the
>Internet.
>But when I try to check for an connection (using the Inet control) there
>pops up the 'Connect To' window (the one where you have to enter your
>user name, password and phone-number and then press 'Connect')

>On my computer that screen also appears when I start Netscape, FTP and
>Explorer.

>Please, anyone who knows the answer....... Please tell me...

>Thanks,

> JB



Sat, 08 Jul 2000 03:00:00 GMT  
 Advanced: CHECK for Internet Connection

I know I have seen posted here in the last month or two the name and
arguments of an API that will tell you if there is a valid internet dial-up
connection active.  Unfortunatly, I didn't save it myself.

--

Tony Selke

(please remove the _No-Junk-Mail_ prior to responding)

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Quote:
>>"How do you CHECK whether the user is logged on to the Internet ?"



Tue, 11 Jul 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Advanced: CHECK for Internet Connection

2. checking internet connection from .net

3. Check Internet Connection

4. Checking for client internet connection.

5. Checking an Internet Connection

6. Checking for active internet connection.

7. Check Internet Connection

8. Check for internet connection

9. Checking an Internet Connection

10. Checking for Internet connection

11. checking for internet connection in NT

12. How to check for internet connection?

 

 
Powered by phpBB® Forum Software