?
Solved

how can i test a internet link?

Posted on 2011-03-20
7
Medium Priority
?
289 Views
Last Modified: 2012-05-11
I have a form that may test if the internet and local link is activ. How can i do that?
thanks
0
Comment
Question by:luciliacoelho
7 Comments
 
LVL 43

Expert Comment

by:pcelba
ID: 35177699
You may use code from this link: http://fox.wikis.com/wc.dll?Wiki~HowtoPingRemoteSite

The "ping" will tell if you are connected and the second source will test DNS availability.

Many more similar routines exist.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 35178260
I did it like this. I create a hidden webbrowser in a class and check if google or any other website opens.

FUNCTION IsInternetConnectionAvailable
WITH oWebBrowser
      .Navigate2("http://www.google.com")
      DO WHILE .ReadyState <> 4 && Wait till it opens
      ENDDO
ENDWITH
RETURN "google" $ LOWER(oWebBrowser.Document.body.innerText)
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 35178292
I forgot to add the class and the initiation to the above.

DEFINE CLASS WebBrowser AS OLECONTROL
      OLEClass = "Shell.Explorer"
ENDDEFINE

FUNCTION IsInternetConnectionAvailable
LOCAL oWebBrowser
oWebBrowser = CreateObject("WebBrowser")
WITH oWebBrowser
      .Navigate2("http://www.google.com")
      DO WHILE .ReadyState <> 4 && Wait till it opens
      ENDDO
ENDWITH
RETURN "google" $ LOWER(oWebBrowser.Document.body.innerText)

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 35179458
You may use this: http://msdn.microsoft.com/en-us/library/aa384346%28VS.85%29.aspx

#DEFINE FLAG_ICC_FORCE_CONNECTION  1

DECLARE INTEGER InternetCheckConnection IN wininet;
    STRING lpszUrl, INTEGER dwFlags, INTEGER dwReserved
 
? InternetCheckConnection("http://www.google.com",FLAG_ICC_FORCE_CONNECTION,0)

Open in new window


You can also check general availability of Internet via InternetCheckConnection(NULL,FLAG_ICC_FORCE_CONNECTION,0)

Bye, Olaf.
0
 

Author Comment

by:luciliacoelho
ID: 35412888
i try the CaptainCyril solution, but i put the code in a VFP method, and the result is an error. How can i creat the class?
thanks
0
 
LVL 27

Accepted Solution

by:
CaptainCyril earned 2000 total points
ID: 35413502
Yes I am sorry. The webbrowser has to be in a form or container to work.

? IsInternetConnectionAvailable()

DEFINE CLASS WebBrowser AS OLECONTROL
      OLEClass = "Shell.Explorer"
ENDDEFINE

FUNCTION IsInternetConnectionAvailable
LOCAL oWebBrowserForm
oWebBrowserForm = CREATEOBJECT("WebBrowserForm")
WITH oWebBrowserForm.WebBrowser
      .Navigate2("http://www.google.com")
      DO WHILE .ReadyState <> 4 && Wait till it opens
      ENDDO
ENDWITH
RETURN "google" $ LOWER(oWebBrowserForm.WebBrowser.Document.body.innerText)

DEFINE CLASS WebBrowserForm AS FORM
      ShowWindow = 2
      Visible = .F.

      ADD OBJECT WebBrowser AS WebBrowser
ENDDEFINE
0
 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 35417285
luciliacoelho.

you can't put defines into a method, this code needs to be in a PRG or you redo that with visual classes in vcxes.

Bye. Olaf.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question