Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Online or Not...
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00281401
Message ID:
00284760
Vues:
22
>>>Hi Eric,
>>>
>>>>Which API will tell me if I am connected to the Inet or not and of not call up the Win Dialer and connect without prompting?
>>>
>>>Declare Integer InternetGetConnectedState in WinINet.Dll Long @lpdwFlags, Long dwReserved
>>>lnFlags = 0
>>>? InternetGetConnectedState(@lnFlags,0)
>>>This function returns 0, if not connected, any other value if connected. The flags can be used to determine additional information, like connected via modem, LAN, Proxy, etc.
>>>
>>>Christof
>>
>>
>>Christof- this function doesn't work correctly, and never has. It is not dependable in a LAN or a dial-up situation. Believe me, I battled with it for a long time before having my suspicions confirmed by others (Rick Strahl one of them).
>>
>>Eric-
>>I have discovered a useful alternative function to be much more reliable:
>>
>>DECLARE INTEGER InternetAttemptConnect IN Wininet.dll INTEGER
>>=InternetAttemptConnect(0)
>>
>>This is a modal function that will check to see if the computer is connected, and if not, initiate the default dialup connection, and wait for the connection to complete or fail. If the machine is already connected, it just immediately returns 0.
>>
>>It does NOT give you a handle on the session though, which you will need if you want to programmatically disconnect after you are finished.
>
>
>Erik,
>
>I tried the following from the command window:
>
>DECLARE INTEGER InternetAttemptConnect IN Wininet.dll;
> integer InternetAttemptConnect(0)
>? InternetAttemptConnect(0)
>
>but it returns 0 everytime, connected or not. I can't tell if it is attempting to initiate the default connection or not but if I call the function it returns 0 and I'm still not connected afterward. Are there other parameters I'm leaving out?

It looks like you fudged the DECLARE a little bit, but O'm not sure what effect that might have on the function. Note in my first post, the entire DECLARE is on the first line- you don't need the parens with the 0 at the end.

Also, is your computer connected to a network that might fool the function into thinking its online?

What happens when you open Internet Explorer when you are offline- do you get a Dial-up box? This is exactly what should happen with the posted function.
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform