Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find out from VFP if there is a "live" internet connection 1

Status
Not open for further replies.

tamayok

Programmer
Sep 4, 2001
99
PR
Is there a way to find out if a workstation has a live internet connection?

I have tried the following command at the DOS promt:

IPConfig.EXE /ALL > SomeFile.TXT

When I have a live connection, SomeFile.TXT lists
(in my Windows 2000 station):

PPP adapter MyDialUp DialUp

However the same DOS command reveals no similar entry on my Windows 98 station.

Is there a reliable way of finding this out?
What should I look for if its NOT a DialUp?

A final (strange) issue: SomeFile.TXT contains fewer entries when invoked as a RUN IPConfig.EXE /ALL > SomeFile.TXT from FPW2.6a than issuing the same request from VFP7. Why?

Many thanks!
KT



 
Here's a little routine that will check your connection:

DECLARE INTEGER InternetAttemptConnect IN wininet;
INTEGER dwReserved

&&... returns 0 if connected
IF InternetAttemptConnect(0) = 0
WAIT WINDOW 'There is an internet connection' NOWAIT
ELSE
WAIT WINDOW 'There is no internet connection' NOWAIT
ENDIF

Dave S.
 
Thanks DSummZZZ! Your routine is what I was looking for. Great job!!

KT
 
Dave

I coppied that code and I pasted it, and I tried it.
It always returs that "I DO" have a connection.

Though, I Unplugged my netwrok cable, and I don't have Internet anymore, and I even Rebooted my machine "Without" the cable.

And It still said that "I DO" have connection!!

What is the solution?

Thank you Dave Tekno
 
Hmmm. That's what I get too. [dazed]

This one seems to work better:

DECLARE INTEGER InternetCheckConnection in wininet;
STRING lpszUrl,;
INTEGER dwFlags,;
INTEGER dwReserved

IF InternetCheckConnection(" 1, 0) = 1

WAIT WINDOW 'There is an internet connection' NOWAIT
ELSE
WAIT WINDOW 'There is no internet connection' TIMEOUT 2
ENDIF

Note: = 1 instead of = 0.
1 = connection, 0 = not

Dave S.
 
On my machine, which as a good proxy connection through a proxy on a different machine on my network, this returns that there is NO internet connection, which is technically correct, but browsing works well anyway! (Win2k, HTTP proxy, tcp/ip 10baseT lan)
 
Sorry if my question opened a "can-of-worms" (!)... The initial routine worked well for me, probably because I am using a basic Dial-Up. Here, when there is no connection, the "Connect to" dialogue is called.

I suspect there is a way, without calling specific pages, to find this out from the operating system.

Thanks to all! Awesome forum....

 
I'm glad the original on worked for you. As a side note though, I think the 1 as the second parameter:

IF InternetCheckConnection(" ", ;
1, 0) = 1

is supposed to call the Connect To dialog if there is no connection. I think 0:

IF InternetCheckConnection(" ", ;
0, 0) = 1

is supposed to just check for a connection. I haven't tested this theory yet so don't take my word for it.

Dave S.
 
FYI


lpszUrl
Pointer to a string containing the URL to use to check the connection. This value can be set to NULL.

dwFlags
Unsigned long integer value containing the flag values. FLAG_ICC_FORCE_CONNECTION is the only flag that is currently available. If this flag is set, it forces a connection. A sockets connection is attempted in the following order.
I found this bit particularly intersting
If lpszUrl is non-NULL, the host value is extracted from it and used to ping that specific host.
If lpszUrl is NULL and there is an entry in the Microsoft® Win32® Internet (WinInet) internal server database for the nearest server, the host value is extracted from the entry and used to ping that server.

dwReserved
Reserved. Must be set to 0.
-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top