user191582
user191582

Reputation: 23

InternetCheckConnection in VB6 returning false

I'm trying to come up with a VB6 test app that calls InternetCheckConnection.

In my test app, InternetCheckConnection always returns false regardless of the URL I use. I copied and pasted this code from a larger spaghetti-code app, but in the spaghetti-code, InternetCheckConnection seems to work fine, returns true.

Is there some other function I have to call first in order for InternetCheckConnection to work?

Upvotes: 1

Views: 1118

Answers (3)

dretzlaff17
dretzlaff17

Reputation: 1719

Try using the InternetGetConnectedState function.

Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpSFlags As Long, ByVal dwReserved As Long) As Long

Dim blnInternetConnected as Boolean
Dim Flags as long

blnInternetConnected = InternetGetConnectedState(Flags, 0&)

Upvotes: 1

Kenny
Kenny

Reputation: 356

I was able to get InternetCheckConnection to work correctly by including the full address for a website, including "http://". For example, using "www.google.com" returned False, but "http://www.google.com" returned true.

Upvotes: 1

Stuart Helwig
Stuart Helwig

Reputation: 9454

Perhaps, in the "spaghetti-code" app, InternetCheckConnection is relying on the state of some global variable you are not aware of. Is that possible?

Upvotes: 0

Related Questions