| View previous topic :: View next topic |
| Author |
Message |
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Oct 10th, 2003 07:32 AM Post subject: Check status of internet connection |
|
|
| 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 |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Oct 10th, 2003 07:35 AM Post subject: |
|
|
| 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 |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Oct 10th, 2003 07:36 AM Post subject: |
|
|
| 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 |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Oct 10th, 2003 07:36 AM Post subject: |
|
|
| 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 |
|
|