WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WinInet
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

iGetConState Returns False


Question:

I am testing for a "live" internet connection using
AddExtender("WWINT44I.DLL")
isconnected=iGetConState(0)
On of my client, under Win2K always gets a false value for isconected even though he can access the Web through IE. Am I missing something?

Answer:

Note: the iGetConState function can return @FALSE when connected to the Internet, if there is an unconfigured Default Gateway value.... http://support.microsoft.com/default.aspx?scid=kb;en-us;315035 Also, apparently the iGetConState function can only really be used to determine if there is a default Internet dialup connectoid configured and whether it is currently active or not. If there is a default Internet dialup connectoid configured and it is not currently active then iGetConState will return FALSE.

You cannot rely solely on the fact that iGetConState returning TRUE means that you have a valid active Internet connection. It is impossible for iGetConState to determine if the entire connection to the Internet is functioning without sending a request to a server. This is why you need to send a request to determine if you are really connected or not. You can be assured however that if iGetConState returns TRUE, that attempting your connection will NOT cause you to be prompted to connect to the default Internet Service Provider.

Be aware that iGetConState only reports the status of the default Internet connectoid on Internet Explorer 4.x. If a nondefault connectoid is connected, iGetConState always returns FALSE (unless a LAN connection is used). With Internet Explorer 4.x configured to use a LAN connection, iGetConState always returns TRUE.

Internet Explorer 5 behaves differently. If you are currently dialed into a different dial-up in Internet Explorer 5, iGetConState reports dial-up connection status as long as any connectoid is dialed or an active LAN connection exists.

Here is some sample code that actaully attempts to connect to the internet. It is really the only way to be sure there is a connection.

AddExtender("WWINT44I.DLL")
If iGetConState(0) == @FALSE
   ; Don't attempt connection or it will bring up the dialog
   ; ...
   Exit
EndIf
ERROR_NAME_NOT_RESOLVED = 12007
ERROR_CANNOT_CONNECT = 12029
ERROR_TIMEOUT = 12002
; Attempt connection
tophandle=iBegin(0,"","")
datahandle=IUrlOpen(tophandle,"http://www.winbatch.com")
If datahandle == 0
     ; Call failed
     err = iGetLastError();
     If err == ERROR_NAME_NOT_RESOLVED || err == ERROR_CANNOT_CONNECT || err == ERROR_TIMEOUT
         ; probably not connected...handle appropriately
         ;...
         Exit
     EndIf
 EndIf
 ; We're connected!!!
 ; ....
 Message("Notice","Successfully connected")

 ;Clean up
 iClose(datahandle)
 iClose(tophandle)

Article ID:   W16892
File Created: 2007:07:03:14:26:44
Last Updated: 2007:07:03:14:26:44