Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Test for internet connection.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00290730
Message ID:
00290788
Vues:
11
>Anyone know how to test the current workstation to see if it's connected to the internet from within the VFP app?

There are several ways to do this-

the documented method uses the GetInternetConnectedState function in WinInet.dll, but unfortunately, this method has never worked correctly, and is unreliable.

My favorite is a dual purpose function that fires up a dial-up dialog if the machine is connected, and just returns 0 if it is. The call is modal, so it waits to see if the dial up succeeds before returning a value.

DECLARE Integer InternetAttemptConnect IN WinInet.dll INTEGER
?InternetAttemptConnect(0)

The function returns 0 if a connection is present, and a Win32 error code if it is not.

If you need a quiet way to tell if a connection is present without attempting a dialup connection, there are several other ways- one is running the DOS PING command and directing the output to a file, and then reading and parsing the contents of the file. Try a search here on PING. There are other methods in the WinInet library, but they all rely on hitting an IP and waiting for a timeout...
Erik Moore
Clientelligence
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform