Solved

how can i test a internet link?

Posted on 2011-03-20
7
272 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 41

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now