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.

How to use iGetConState

 Keywords:  Detect User Connected Modem iGetConState

Question:

I used the following code...

It returned wrong number, I can't find the number in the hlp file.

AddExtender("WWINT34I.DLL")
isconnected=iGetConState(0)
if isconnected==0
  message("No Connection","User is not connected to internet")
  exit
endif
message("Connection","User is connected to internet")
constate=iGetConState(1)

pause("debug",constate) ;returns 81 or 86 - Wininet extender v25049

switch constate
case 1
str="INTERNET_CONNECTION_MODEM... Local system uses a modem to
connect to the Internet."
break
case 2
str="INTERNET_CONNECTION_LAN... Local system uses a local area network
to connect to the Internet."
break
case 4
str="INTERNET_CONNECTION_PROXY... Local system uses a proxy server to
connect to the Internet."
break
case 8
str="INTERNET_CONNECTION_MODEM_BUSY (NO LONGER USED)... Local
system's modem is busy with a non-Internet connection."
break
case 16
str="INTERNET_RAS_INSTALLED... Local system has RAS installed."
break
case 32
str="INTERNET_CONNECTION_OFFLINE... Local system is in offline mode."
break
case 64
str="INTERNET_CONNECTION_CONFIGURED... Local system uses a proxy
server to connect to the Internet."
break

endswitch
message("How is the user connected?",str)

exit 

Answer:

The number is a bit mask.
81 is 64 + 16 + 1
86 is 64 + 16 + 4 + 2
Requires different logic...like...
AddExtender("WWINT34I.DLL")
isconnected=iGetConState(0)
if isconnected==0
message("No Connection","User is not connected to internet")
exit
endif
message("Connection","User is connected to internet")
constate=iGetConState(1)

pause("debug",constate) ;returns 81 or 86 - Wininet extender v25049

str=""

if constate & 1
   str=strcat(str,"INTERNET_CONNECTION_MODEM... Local system uses a modem to connect to the Internet.",@crlf)
endif
if constate &  2
   str=strcat(str,"INTERNET_CONNECTION_LAN... Local system uses a local area network to connect to the Internet.",@crlf)
endif
if constate &  4
   str=strcat(str,"INTERNET_CONNECTION_PROXY... Local system uses a proxy server to connect to the Internet.",@crlf)
endif
if constate &  8
   str=strcat(str,"INTERNET_CONNECTION_MODEM_BUSY (NO LONGER USED)... Local system's modem is busy with a non-Internet connection.",@crlf)
endif
if constate &  16
   str=strcat(str,"INTERNET_RAS_INSTALLED... Local system has RAS installed.",@crlf)
endif
if constate &  32
   str=strcat(str,"INTERNET_CONNECTION_OFFLINE... Local system is in offline mode.",@crlf)
endif
if constate &  64
   str=strcat(str,"INTERNET_CONNECTION_CONFIGURED... Local system uses a proxy server to connect to the Internet.",@crlf)
endif

message("How is the user connected?",str)
exit

Article ID:   W14804
File Created: 2017:07:28:13:58:46
Last Updated: 2002:07:15:12:59:11