Solved

How do I detect whether of not an Internet connection exists?

Posted on 1997-04-06
6
168 Views
Last Modified: 2010-04-06
My problem is that I need to test whether or not a connection to the internet exists in windows95.  The obvious solution is to test your own IP address and compare it to 127.0.0.1 .  If the comparison is true, your offline.  Any other IP address means your online.

The problem is that with windows95, any call to winsock triggers the dialer.  I DO NOT want to trigger the dialer if there is no connection to the internet.

So, I guess my question is:

   How do I make a call to Winsock without triggering the dialer?

0
Comment
Question by:sleach
  • 4
  • 2
6 Comments
 
LVL 1

Author Comment

by:sleach
Comment Utility
Edited text of question
0
 
LVL 1

Author Comment

by:sleach
Comment Utility
Adjusted points to 204
0
 
LVL 3

Accepted Solution

by:
sperling earned 200 total points
Comment Utility
Might work using the RasEnumConnections API call...

If you need help using this function, let me know.

Regards,

Erik.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Author Comment

by:sleach
Comment Utility
sperling, I am unfamiliar with RAS.  Can you point me to a code example?  

Also, will RasEnumConnections show only dial up networking connections, or will it also show connections from other dialers(such as AOL's 32 bit dialer)?

I am currently using FindWindow to detect the Win95 Dialer, but this only works with the Win95 Dialer.  I need a method thats Dialer independant.

Can RAS be used to disable the AutoDial feature?
0
 
LVL 3

Expert Comment

by:sperling
Comment Utility
>sperling, I am unfamiliar with RAS. Can you point me to a code
>example?

So am I ;)

I haven't got any modems installed, and I don't run 95... Therefore I can just suggest that you make a small test program displaying RasEnumConnections output in an ButtonClick event, and then tries to figure out how it works by noting what output you get while offline and online using different dialers.

Sorry I can't be of more help.

Regards,

Erik.
0
 
LVL 1

Author Comment

by:sleach
Comment Utility
It took me awhile, but I finally figured it out.

For the purpose of sharing the solution, Here is the function that works for me.

USES ras;

function RasConnected:  boolean;
var
    rasconnbuf:  TRasConn;
    cb, ret, numConn:  integer;
    connected:  boolean;
begin

    //Required to provide buffer size
    rasconnbuf.dwSize := sizeof(rasconnbuf);
    cb := sizeof(TRasConn);

    //Retrieve info about first active connection (I only have one - change this if you have more)
    ret := RasEnumConnections(@rasconnbuf, cb, numConn);

    if ((numConn = 0) or (ret <> 0)) then connected := false
    else Connected := true;
result := connected;
end;

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now