CheckInternetConnection

Share your advanced PureBasic knowledge/code with the community.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

CheckInternetConnection

Post 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)  
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post 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
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

http://msdn.microsoft.com/library/defau ... dstate.asp

I think RAS mean "Remote Access Services"
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post 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
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post 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 ?
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

dell_jockey wrote:now that made me sit up and listen! Are you using finance.yahoo ?
Yes.
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post 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.
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Sorry, no.

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

cheers
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

ok, thanks!
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: CheckInternetConnection

Post 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).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Cool we have 2003 / 2004 / 2005 Post, who post this topic in 2006 :lol:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Uh-oh, I suspect this will become a running gag now. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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.
@}--`--,-- A rose by any other name ..
Post Reply