Navigation: Introducing thinBasic > Example 6 |
|
Test if computer is connected to Internet, in which way and report IPs.
Uses "INet"
Uses "RAS"
'--------------------------------------------------------------------------
'Check if connection to internet is active
'If not active standard connection dialog box is started
'--------------------------------------------------------------------------
Function RunConnectToInternet() As Long
'--------------------------------------------------------------------------
Dim IConnected As Long
Dim Message As String
Function = True
'--- Check current connection status
IConnected = INET_GetState
'---
'If already connected then use current connection
'otherwise try to make a connection
'---
If IConnected = False Then
'-If not connected, try to run AutoDialing windows functionality
Ras_OpenDialUpDialog
'-Check again connection
IConnected = INET_GetState
'-If not connect again, error message
If IConnected = False Then
Message = "It was not possible to connect to Internet.\n\n"
MsgBox 0, Message, %MB_OK OR %MB_ICONEXCLAMATION, "Error During Internet Connection."
Function = False
End If
End If
End Function
'----------------------------------------------------------------------
'Main program
'----------------------------------------------------------------------
Dim Msg As String
Dim IPCount As Long
If RunConnectToInternet() = True Then
Msg = "You are connected to Internet.\n" + _
"Your current connection mode is: " + INET_GetConnectionMode + "\n"
Else
Msg = "You are NOT connected to Internet.\n"
End If
Msg = Msg + "You have " + INET_GetIP(0) + " IPs on your box.\n"
If INET_GetIP(0) > 1 Then
Msg = Msg + "They are:\n"
Else
Msg = Msg + "It is:\n"
End If
For IPCount = 1 To INET_GetIP(0)
Msg = Msg + INET_GetIP(IPCount) + "\n"
Next
MsgBox 0, Msg
© 2004-2008 thinBasic. All rights reserved. | Version 1.7.0.0 | Web Site: http://www.thinbasic.com |