Page 1 of 1

CheckInternetConnection

Posted: Sun Nov 06, 2005 7:11 pm
by Droopy
Code updated for 5.20+

To view Internet connection configuration

Code: Select all

; Return :
; 0x40 INTERNET_CONNECTION_CONFIGURED : Local system has a valid connection To the Internet, but it might Or might not be currently connected.
; 0x02 INTERNET_CONNECTION_LAN : Local system uses a Local area network To connect To the Internet.
; 0x01 INTERNET_CONNECTION_MODEM : Local system uses a modem To connect To the Internet.
; 0x08 INTERNET_CONNECTION_MODEM_BUSY : No longer used.
; 0x20 INTERNET_CONNECTION_OFFLINE : Local system is in offline mode.
; 0x04 INTERNET_CONNECTION_PROXY : Local system uses a proxy server To connect To the Internet.
; 0x10 INTERNET_RAS_INSTALLED : Local system has RAS installed
; or 0 if  there is no Internet connection


ProcedureDLL CheckInternetConnection()
  InternetGetConnectedState_(@Retour, 0)
  ProcedureReturn Retour
EndProcedure

;/ Test

State=CheckInternetConnection()

If State=0
  Temp.s="No Internet Connection"
EndIf
 
If State & #INTERNET_CONNECTION_CONFIGURED
  Temp="INTERNET_CONNECTION_CONFIGURED"+#CRLF$
EndIf

If State &#INTERNET_CONNECTION_LAN
  Temp+"INTERNET_CONNECTION_LAN"+#CRLF$
EndIf

If State &#INTERNET_CONNECTION_MODEM
  Temp+"INTERNET_CONNECTION_MODEM"+#CRLF$
EndIf

If State &#INTERNET_CONNECTION_MODEM_BUSY
  Temp+"INTERNET_CONNECTION_MODEM_BUSY"+#CRLF$
EndIf

If State &#INTERNET_CONNECTION_OFFLINE
  Temp+"INTERNET_CONNECTION_OFFLINE"+#CRLF$
EndIf

If State &#INTERNET_CONNECTION_PROXY
  Temp+"INTERNET_CONNECTION_PROXY"+#CRLF$
EndIf

If State &#INTERNET_RAS_INSTALLED
  Temp+"INTERNET_RAS_INSTALLED"+#CRLF$
EndIf

MessageRequester("Internet Connexion",Temp)  

Posted: Sun Nov 06, 2005 7:17 pm
by josku_x
thanks! just sweet as I need it :D !

You are great and your LIB is great!

EDIT: By the way, does RAS mean "Remote Access Server" ? Because the program tells me that I googled about it and it came to be Remote Access Server. Ofcourse I am not reporting a bug, I really have a server :D

Posted: Sun Nov 06, 2005 8:19 pm
by Droopy
http://msdn.microsoft.com/library/defau ... dstate.asp

I think RAS mean "Remote Access Services"

Posted: Sun Nov 06, 2005 10:02 pm
by rsts
yes - nice one.

i do a lookup on stock quotes in one of my programs, this will be a nice check to add.

cheers

Posted: Sun Nov 06, 2005 10:42 pm
by dell_jockey
rsts wrote:i do a lookup on stock quotes in one of my programs
now that made me sit up and listen! Are you using finance.yahoo ?

Posted: Sun Nov 06, 2005 10:45 pm
by rsts
dell_jockey wrote:now that made me sit up and listen! Are you using finance.yahoo ?
Yes.

Posted: Sun Nov 06, 2005 10:47 pm
by dell_jockey
rsts wrote:
dell_jockey wrote:now that made me sit up and listen! Are you using finance.yahoo ?
Yes.
do you happen to know internet sources for intra-day (non-delayed) quotes - preferably not just stocks, I'm interested in futures and forex as well.

Posted: Sun Nov 06, 2005 10:50 pm
by rsts
Sorry, no.

I just use quotes.yahoo to do stock/mutual fund lookups to determine day gain, portfolio value type info.

cheers

Posted: Sun Nov 06, 2005 10:55 pm
by dell_jockey
ok, thanks!

Posted: Tue Jan 17, 2006 10:11 am
by Psychophanta

Re: CheckInternetConnection

Posted: Tue Jan 17, 2006 11:14 am
by PB
To all: don't forget to search before posting tips... this tip has been seen
twice before in both 2003 and 2004, in almost exactly the same code:

2003 = viewtopic.php?t=5590
2004 = viewtopic.php?t=10052

Thanks. (And for what it's worth, it drew attention to the fact the the
Windows Residents file is missing the "INTERNET_*" constants, so I've
just added them for the next PureBasic release).

Posted: Tue Jan 17, 2006 12:36 pm
by Droopy
Cool we have 2003 / 2004 / 2005 Post, who post this topic in 2006 :lol:

Posted: Tue Jan 17, 2006 12:42 pm
by PB
Uh-oh, I suspect this will become a running gag now. :)

Posted: Tue Jan 17, 2006 1:28 pm
by Dare2
Droopy wrote:Cool we have 2003 / 2004 / 2005 Post, who post this topic in 2006 :lol:
PB wrote:Uh-oh, I suspect this will become a running gag now. :)
:D


Well, the 2005 post was a JIT thing for me. (belated) thanks.