Connected to the net?

I searched alot for an answer to this question but no luck.
I want to know if I am connected to the internet or not, I may be connected from another computer (lan).

Some of the answer they gave me:
-Ping website
its not good since my program is going to check for internet connection every sec, and using batch wont be good then
-API --> GetConnectionStat / InternetConnectionEx / IsConnected
all these are telling me that I am connected to the net when I am only connected to the network

I got many other answers but the codes wount be able to tell me that I am connected to the net when I am recieving connection from another PC
can u help?
thx
instant_newAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dbrckoviCommented:
Try creating a new Web Browser form. Set its MDIChild property to False.
On Form1 create one command button and one timer.
Paste this code:
------------------------------------
Private Sub Command1_Click()
    frmBrowser.cboAddress.Clear
    frmBrowser.cboAddress.AddItem "www.google.com"
    frmBrowser.cboAddress.ListIndex = 0
   
    Timer1.Interval = 1000
    Timer1.Tag = 1
    Timer1.Enabled = True
End Sub

Private Sub Form_Load()
    Load frmBrowser
    frmBrowser.Hide
End Sub

Private Sub Timer1_Timer()
    Timer1.Tag = Timer1.Tag + 1
    If Timer1.Tag = 60 Then
        Form1.Caption = "Not connected ... try again later"
        Timer1.Enabled = False
        Exit Sub
    End If
   
   
    Form1.Caption = "Waiting..."
    If frmBrowser.Caption = "Google" Then
        Form1.Caption = "Connected"
        Timer1.Enabled = False
    End If
End Sub
-----------------------------------------
Each time you click a button, request for openning google page will be sent.
Timer will then check every second if frmBrowsers caption was changed.
If it doesn't change to "Google" in 60 seconds, then you are probably not connected.   ( I think 60 sec should be more than enough to load google )
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
instant_newAuthor Commented:
@dbrckovi
well that worked, but there must be a better way, without using a Web Browser Form...
I'll wait for new replies if not u will get points

@EDDYKT
it is always saying Reachable >> No
it isnt working, although it would be great if it worked.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

EDDYKTCommented:
Try this

Option Explicit

Const NETWORK_ALIVE_AOL = &H4
Const NETWORK_ALIVE_LAN = &H1
Const NETWORK_ALIVE_WAN = &H2
Private Type QOCINFO
    dwSize As Long
    dwFlags As Long
    dwInSpeed As Long 'in bytes/second
    dwOutSpeed As Long 'in bytes/second
End Type
Private Declare Function IsDestinationReachable Lib "SENSAPI.DLL" Alias "IsDestinationReachableA" (ByVal lpszDestination As String, ByRef lpQOCInfo As QOCINFO) As Long
Private Sub Form_Load()
    'KPD-Team 2001
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Dim Ret As QOCINFO
    Ret.dwSize = Len(Ret)
    If IsDestinationReachable("www.allapi.net", Ret) = 0 Then
        MsgBox "The destination cannot be reached!"
    Else
        MsgBox "The destination can be reached!" + vbCrLf + _
           "The speed of data coming in from the destination is " + Format$(Ret.dwInSpeed / 1024, "#.0") + " Kb/s," + vbCrLf + _
           "and the speed of data sent to the destination is " + Format$(Ret.dwOutSpeed / 1024, "#.0") + " Kb/s."
    End If
End Sub
 


From http://www.mentalis.org/apilist/IsDestinationReachable.shtml
0
dbrckoviCommented:
I agree that there must be a better way.
Take my example just as a backup sollution if nothing else works.
In the meanwhile, I would suggest you to stick with EDDYKT. He might be on the right track.

0
leonstrykerCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split dbrckovi, EDDYKT
 
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

leonstryker
EE Cleanup Volunteer
0
dbrckoviCommented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.