internet connection status

BlitzPlus Forums/BlitzPlus Programming/internet connection status

Timjo(Posted 2007) [#1]
Is there a way within blitzplus to determine whether or not my computer is connected to the internet. As in START - Connect To - Show All Connections - which shows your internet access status (connected/disconnected). Thanks. TimJo.


Nebula(Posted 2007) [#2]
Read a pixel from the desktop if you have a online icon.


Timjo(Posted 2007) [#3]
I think I know what you're getting at, Nebula, but how would you know whereabouts to read the pixel on the desktop ? Clever solution though.


plash(Posted 2007) [#4]
Not too clever, if the icon is shown in the system tray (which it should), it can be in a different location every time.


Gabriel(Posted 2007) [#5]
http://msdn2.microsoft.com/en-us/library/ms647415.aspx


Timjo(Posted 2007) [#6]
That's not too big a problem - as I can scan across the system tray - the problem is that if the mouse pointer is over the icon when I check for it's existance it can mess things up.
Is there a way to temporarily hide the pointer when over the desktop/system tray - as I check ? - the hide/showpointer commands only work with canvases.


Timjo(Posted 2007) [#7]
Hmm... after a quick re-check - the mouse pointer doesn't seem to affect this after all. (I expect the more technically aware of you out there know why it doesn't seem to register with a readpixel command - maybe a sprite or something - I don't know).


plash(Posted 2007) [#8]
Create a file called "url.decls" in your blitzplus\userlibs folder (by default: C:\Program Files\BlitzPlus\userlibs), copy and paste the following...

.lib "url.dll"

InetIsOffline%(dwFlags%)


Save the file and go into your IDE, test the following code..

Notify InetIsOffline%(0)


If it returns 0, that means your connected to the internet, if it returns 1 that means your not connected.


xlsior(Posted 2007) [#9]
Hm... Any ideas on how to call that one from BlitzMax?


plash(Posted 2007) [#10]
So far I've got this

SuperStrict

Extern "win32"
	Function LoadLibrary:Int(name$z) = "LoadLibraryA@4"
	Function GetProcAddress:Byte Ptr ( Library:Int , Name$z )
EndExtern


Local urld:Int = LoadLibrary( "C:\WINDOWS\system32\url.dll" )
Local InetIsOffline:Int(dwflags:Int) = GetProcAddress ( urld , "InetIsOffline" )


Notify InetIsOffline:Int(0)


Connected or not, it will always return 0, dunno what I did wrong here..


Timjo(Posted 2007) [#11]
I tried the 'url.decls' thing in BlitzPlus - but it gave me '0' whether connected on not connected.


Alaric(Posted 2007) [#12]
How is he supposed to call a command from a dll that doesn't exist? Won't he need to copy the C:\windows\system32\url.dll to his blitzplus userlib directory first?


xlsior(Posted 2007) [#13]
Plash: That's pretty much exactly what I tried as well, with the same results. :-?


Alaric(Posted 2007) [#14]
Returns TRUE if the local system is not currently connected to the Internet. Returns FALSE if the local system is connected to the Internet or if no attempt has yet been made to connect to the Internet. I got this from msdn, I'm not sure what exactly the last line means, but it could be your problem.


Sonari Eclipsi Onimari(Posted 2007) [#15]
Oksy, how about this


tcp=opentcpstream("www.google.com",80)
if not tcp then notify "NOT CONNECTED!"




William Drescher(Posted 2007) [#16]
Alaric,
That last part, "if no attempt has yet been made to connect to the Internet," basically means that if the computer hasn't checked to see if it's still connected, and it's not, it's going to tell you that it's still connected to the internet