Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
Check status of internet connection
View previous topic :: View next topic  
Author Message
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Oct 10th, 2003 07:32 AM    Post subject: Check status of internet connection Reply with quote

Code:
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long

Private Const FLAG_ICC_FORCE_CONNECTION = &H1

Private Sub Form_Load()

If InternetCheckConnection("http://www.avissoft.com", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then

MsgBox "No internet connection detected...", vbInformation

Else

MsgBox "Internet connection detected...", vbInformation

End If

End Sub

_________________
No one is completely useless. They can at least be an example of what to avoid.


Last edited by P.T.A.M. on Oct 10th, 2003 07:35 AM; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Oct 10th, 2003 07:35 AM    Post subject: Reply with quote

Code:
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpSFlags As Long, ByVal dwReserved As Long) As Long

Private Sub Command1_Click()
If InternetGetConnectedState(0, 0) Then
   MsgBox "Online"
Else
   MsgBox "Offline"
End If
End Sub

_________________
No one is completely useless. They can at least be an example of what to avoid.
Back to top
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Oct 10th, 2003 07:36 AM    Post subject: Reply with quote

Code:
'Example by Vijay Phulwadhawa (vijaycg44@hotmail.com)
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, ByVal dwNameLen As Integer, ByVal dwReserved As Long) As Long
Dim sConnType As String * 255
Private Sub Form_Load()
   Dim Ret As Long
   Ret = InternetGetConnectedStateEx(Ret, sConnType, 254, 0)
   If Ret = 1 Then
       MsgBox "You are connected to Internet via " & sConnType, vbInformation
   Else
       MsgBox "You are not connected to internet", vbInformation
   End If
End Sub

_________________
No one is completely useless. They can at least be an example of what to avoid.
Back to top
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Oct 10th, 2003 07:36 AM    Post subject: Reply with quote

Code:
Option Explicit

Private Sub Command1_Click()
 Screen.MousePointer = vbHourglass
 With Winsock1
   .Protocol = sckTCPProtocol
   .RemotePort = 80
   .RemoteHost = "www.avissoft.com"
   .Connect
   
   Do While .State <> sckConnected And .State <> sckError
     DoEvents
   Loop
   If .State = sckConnected Then
     Caption = "Online"
   Else
     Caption = "Offline"
   End If
   .Close
   .LocalPort = 0
 End With
 Screen.MousePointer = vbDefault
End Sub

_________________
No one is completely useless. They can at least be an example of what to avoid.
Back to top
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic