Solved

how can i test a internet link?

Posted on 2011-03-20
7
282 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 42

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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 29

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 500 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 29

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

Industry Leaders: 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…
In order to fulfill our mission of inspiring learning in the technology community, Experts Exchange is launching a Course of the Month program. Premium and Team Account members will have access to one course per month as a part of their membership, …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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