|
-
Jul 5th, 2006, 03:59 AM
#1
Thread Starter
Member
[RESOLVED] how to know the internet connection is available or not?
hi guys
I#m new in VB and this forum..
I have question about, the synbtax to recognize an internet connection.
so, I want to make a program that automatically start when the internet is online or when its connected to the LAN..
can u guys help me with the syntax necessary?
-
Jul 5th, 2006, 09:16 AM
#2
Hyperactive Member
Re: how to know the internet connection is available or not?
One API call:
Declarations:
VB Code:
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
Code Neccessary:
VB Code:
If InternetCheckConnection("http://www.google.com/", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
MsgBox "Connection to google failed!", vbInformation
Else
MsgBox "Connection to google succeeded!", vbInformation
End If
That should do it.
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Jul 5th, 2006, 12:19 PM
#3
Thread Starter
Member
Re: how to know the internet connection is available or not?
but that means, if the LAN available but the internet does not, it will have failed message..
I was thinking about checking the activities in komputer port. or there is much more simple way to do it?
where can i find the documentation of that function?
thanks
-
Jul 5th, 2006, 02:59 PM
#4
Hyperactive Member
Re: how to know the internet connection is available or not?
That should tell you if you are connected to a network. It will also tell you which type.
VB Code:
Const NETWORK_ALIVE_AOL = &H4
Const NETWORK_ALIVE_LAN = &H1
Const NETWORK_ALIVE_WAN = &H2
Private Declare Function IsNetworkAlive Lib "SENSAPI.DLL" (ByRef lpdwFlags As Long) As Long
Private Sub Form_Load()
Dim Ret As Long
If IsNetworkAlive(Ret) = 0 Then
MsgBox "The local system is not connected to a network!"
Else
MsgBox "The local system is connected to a " + IIf(Ret = NETWORK_ALIVE_AOL, "AOL", IIf(Ret = NETWORK_ALIVE_LAN, "LAN", "WAN")) + " network!"
End If
End Sub
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Jul 5th, 2006, 03:26 PM
#5
Thread Starter
Member
Re: how to know the internet connection is available or not?
ok bro now i understand now.. thank you a lot for helping me..
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|