Solved

how can i test a internet link?

Posted on 2011-03-20
7
280 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

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…
The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…

829 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