| View previous topic :: View next topic |
| Author |
Message |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Sun Apr 14, 2002 7:30 am Post subject: connected to the internet |
|
|
I remember someone posting a question about how to determine if a computer is connected to the Internet using VDS. And i can't find that post so i'll put my 2 cents worth here!
Having been in need of such an answer, i did some research and found that the the STATS section of the registry deals with dial up connection data. One of them records the dial up connection and it is 9600 when not connected to the net.
If however you are connected to the net, then that registry entry records your connect speed eg. 31200.
So, i use code like the following to determine using VDS if a computer is connected to the net or not.
| Code: |
%a = @regread(local,System\CurrentControlSet\Control\perfstats\enum\dial-up adapter,name)
%%dummy = @regread(stats,perfstats\statdata,%a\connectspeed)
parse "%1;%2;%3;%4",%%dummy
%%connect_speed = @sum(@sum(@sum(%1,@prod(256,%2)),@prod(65536,%3)),@prod(16777216,%4))
if @equal(%%connect_speed,9600)
rem not connected
else
rem connected
end |
Hope this helps and that it is correct,
Serge _________________
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sun Apr 14, 2002 8:27 am Post subject: |
|
|
Hi, Serge!
I'm afraid that your routine won't work universally - the STATS root is not available
in WinXP (and Win2K, I think). Also various Internet connections, such as DSL, are not
dial-up connections so you will not get viable results from reading values pertaining to
that.
One way of getting a status on Internet connection would be to use a ping command to
ping some stable host on the Internet and interpret the results:
| Code: | runh ping.exe -n 1 www.winzip.com,wait
%%output = @retcode()
if @equal(%%output,0)
info This computer is connected to the Internet
else
info This computer is off-line
end |
There are, of course, a few possible problems doing this: If the host you ping is unreachable
(down or does not exist any more), you will get a false reading. And also you will
have to make sure that PING.EXE is present on the user's system.
You might also use Tommy's new VDSIPING.DLL to do the same thing - it will be faster
and if you won't depend on the presence of PING.EXE.
Another caveat - if the user is behind a firewall that might block off requests from
your program and give a false reading.
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing
Last edited by Dr. Dread on Sun Apr 14, 2002 5:04 pm; edited 1 time in total |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Sun Apr 14, 2002 10:04 am Post subject: |
|
|
Thanks for your comments, Dr. Dread. I'm not concerned in my case with Win XP although i am concerned about other Internet connections.
I will see at work what the story is as we have Internet connection there but not with dial-up. So, i'll see what the registry says about where to look for the necessary information.
It's a shame that there isn't an efficient way. Your ping idea is good but it wouldn't work for my program as i can't have it waiting for the ping return.
Serge _________________
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sun Apr 14, 2002 5:09 pm Post subject: |
|
|
OK Serge, if you find something useable in the registry, please let us know - it might come in handy.
By the way, I updated my ping routine above to do only 1 ping instead of 4 so that should
speed up things considerably.
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1565
|
Posted: Sun Apr 14, 2002 7:37 pm Post subject: |
|
|
I've put together a little dll (23kb) which will allow you to find the status of the users internet connection (0 - offline; 1 - online) and it will also return the IP Address.
You can get it at : http://www.vdsworld.com/index.php?page=download&fileid=176 |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sun Apr 14, 2002 10:23 pm Post subject: |
|
|
| PGWARE wrote: | | I've put together a little dll (23kb) which will allow you to find the status of the users internet connection (0 - offline; 1 - online) and it will also return the IP Address. |
Hi, Prakash! I must say that you're a fast draw. One small problem, though: I think that your DLL
checks online status by looking for an IP (other than 127.0.0.1). You may, however, very well have
an IP address without being connected to the Internet - if you are on an intranet or some other
private network running TCP/IP but not necessarily hooked up to the Internet..... That will
produce a false status reading, I think.
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1565
|
Posted: Mon Apr 15, 2002 12:27 am Post subject: |
|
|
| I'm pretty sure the code is looking for an internet ip rather then a local network assigned ip address. I'm not 100% certain, anyone with a network want to try out the dll and see if it reports the correct online statur or not? |
|
| Back to top |
|
 |
LOBO Valued Contributor


Joined: 14 Mar 2002 Posts: 241 Location: Wilmington, Delaware, USA
|
Posted: Mon Apr 15, 2002 1:06 am Post subject: |
|
|
| PGWARE wrote: | | I'm pretty sure the code is looking for an internet ip rather then a local network assigned ip address. I'm not 100% certain, anyone with a network want to try out the dll and see if it reports the correct online statur or not? |
Prakash,
I disconnected my internet connection from my internal network and tested the dll and got an incorrect response. It still said I was connected to the internet.
- Mark |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Mon Apr 15, 2002 1:21 am Post subject: |
|
|
| PGWARE wrote: | | I'm pretty sure the code is looking for an internet ip rather then a local network assigned ip address. I'm not 100% certain, anyone with a network want to try out the dll and see if it reports the correct online statur or not? |
I just performed this little test: In my TCP/IP network settings, I assigned myself an
IP address (192.168.0.12). Normally I'm permanently hooked up to the Internet with another
address, so assigning myself an IP puts me off-line right away. Calling the DLL still tells
me that I'm on-line. Probably the situation will be the same on a network with a local DHCP
server or with static local IP addresses (connected to the Internet or not).
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing
Last edited by Dr. Dread on Mon Apr 15, 2002 1:36 am; edited 2 times in total |
|
| Back to top |
|
 |
LOBO Valued Contributor


Joined: 14 Mar 2002 Posts: 241 Location: Wilmington, Delaware, USA
|
Posted: Mon Apr 15, 2002 1:35 am Post subject: |
|
|
| Dr. Dread wrote: | I just performed this little test: In my TCP/IP network settings, I assigned myself an
IP address (192.168.0.12). Normally I'm permanently hooked up to the Internet with another
address, so assigning myself an IP puts me off-line right away. Calling the DLL still tells
me that I'm on-line. Probably the situation will be the same on a network with a local DHCP
server or with static local IP addresses (connected to the Internet or not).
|
For clarification my first test also was with a static IP. Just to follow Dread's hunch I enabled my local DHCP server and tested without an internet connection and still got the incorrect results from the dll.
- Mark |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Mon Apr 15, 2002 6:48 am Post subject: |
|
|
_____________________________________________________________
The DLL doesn't work here either (network, static IP also).
This may not work on all systems, but on my Win95
dialup I can check for a "connected" window using
@match() and WINLIST.
Here's an example:
| Code: |
LIST CREATE, 1
LIST WINLIST, 1
if @match(1, "connected")
INFO @item(1)@tab()
else
INFO Not Connected...@tab()
end
|
Cheers, Mac :) _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Mon Apr 15, 2002 12:17 pm Post subject: |
|
|
I posted an example on how to check for local and public IP adresses with a command line freeware I found a while ago and VDS.
Also it's a good way to check if you have an internet connection.
The freeware command line tool is only 63k!
Get it here....
http://www.vdsworld.com/index.php?page=download&fileid=177
Hope this will help you out...

Last edited by marty on Mon Apr 15, 2002 2:41 pm; edited 1 time in total |
|
| Back to top |
|
 |
moke Contributor

Joined: 02 Jan 2002 Posts: 162
|
Posted: Mon Apr 15, 2002 1:19 pm Post subject: |
|
|
I used several differnt methods including ping, to detect internet connections, but none were reliable enough. I now use a routine (using vdsipp.dll) that checks the header of files on 2 different web sites. If the first check fails fails it checks the second. Since both the web sites are mine I set the header criteria so I don't need to worry about defaul error pages giving incorrect results. Because firewalls were a problem I decided that http would probably be the best solution. I use something like this:
| Code: |
INTERNET HTTP,CREATE,1
INTERNET HTTP,THREADS,1,OFF
INTERNET HTTP,PROTOCOL,1,1
INTERNET HTTP,USERAGENT,1,"VDS check"
DIALOG CURSOR, WAIT
INTERNET HTTP,GET,1,http://www.website.com/Checkme.htm
if @equal(@INTERNET(HTTP,CONTENT,1),<foundit>)
%%Connected = yes
else
WARN Unable to find the Internet. Please check your connection@cr()and try again or check with you network administrator.
%%Connected = no
end
INTERNET HTTP,DESTROY,1
|
moke |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Wed Apr 17, 2002 10:44 am Post subject: |
|
|
Just an update to let you know.
I have looked in the registry an found nothing that would help me determine if someone is connected to the net except for the 9600 dialup thing i mentioned earlier.
Thanks for all your comments and suggestions, and for the dll.
I had earlier used IPCONFIG.EXE to determine net connection and found that it worked ok as the Internet IP would show up first and the network one would show up second. So checking that the first IP was not 0.0.0.0 would indicate network connection. Can someone with a permanent connection and a network connection please verify that for me - please
Shame that there isn't an easier answer.
Serge _________________
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed Apr 17, 2002 11:27 am Post subject: |
|
|
| Serge wrote: | | I had earlier used IPCONFIG.EXE to determine net connection and found that it worked ok as the Internet IP would show up first and the network one would show up second. So checking that the first IP was not 0.0.0.0 would indicate network connection. Can someone with a permanent connection and a network connection please verify that for me - please |
Using IPCONFIG/WINIPCFG will have the same flaws as PGWARE's dll - it will show the computer's
current IP address, no matter if the IP is used on the Internet or only on a local TCP/IP network.
Greetz
Dr. Dread
A note: I've been asking around a bit for this, and someone told me that the Internet connection status
can be obtained from a call to RASAPI32.DLL (it should have a function named ISCONNECTED) -
unfortunately VDS cannot do this without a DLL. _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing
Last edited by Dr. Dread on Wed Apr 17, 2002 12:35 pm; edited 1 time in total |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|