Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Check whether a PC has internet access

Posted on 2010-08-30
11
Medium Priority
?
743 Views
Last Modified: 2012-05-10
Any advice on how I'd check if the local system has internet access?

This needs to be compatible with 'standard' Windows operating systems, e.g. 32-bit, Win 95, 98, ME, XP, Vista, 7.

Thanks in advance.
0
Comment
Question by:rfwoolf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 33556887
win95 ?
uh oh ... get out of there !
btw, you missed win3.1

you could use a webbrowser and open google.com
and then check if the document loads

off course there is the possibility your app gets blocked by the firewall
0
 
LVL 14

Assisted Solution

by:Pierre Cornelius
Pierre Cornelius earned 400 total points
ID: 33556936
The best way is to check if you have access to a specific internet resource. E.g. try to ping google or if you know the resource you will be accessing try that one instead.
0
 
LVL 13

Author Comment

by:rfwoolf
ID: 33556990
Thanks guys..
I saw in another PAQ:
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21915452.html
...the solution by HillGroover: a way to ping an address and it returns a boolean result.
This seems to be in line with what I'm looking for, but it's not easy to go and test it on multiple operating systems and with PCs with dialup etc..

Let me know if you have any ideas to top that solution, or if you foresee any problems.

'if you know the resource you will be accessing try that one instead.'
Not sure on what you mean by resource.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 25

Expert Comment

by:epasquier
ID: 33556998
You could use Indy components to do that

TIDIPWatch :
Determines the online status and IP addresses for a computer.

* property IsOnline: Boolean;
Description
IsOnline is a read-only Boolean property used to identify the current online status. IsOnline is updated in the CheckStatus method, and is set to True when the current IP address is not empty ('') or the default local host value 127.0.0.1.

That will tell you if you are connected to your DHCP or have a fixed IP address working, but maybe that will not be enough for you, and you will want to know if you can actually access Internet. That is a start, then you should try other components :

TIdEcho (Ping) with www.google.com is probably the quickest way to check "internet" availability
0
 
LVL 16

Assisted Solution

by:CodedK
CodedK earned 500 total points
ID: 33557059
Hi rfwoolf,

Because of the variety of ways of connecting to the internet and the platform variety you want it to work
there is no real way to check.

So ping Google:
http://delphi.about.com/od/internetintranet/l/aa081503a.htm


0
 
LVL 25

Assisted Solution

by:epasquier
epasquier earned 600 total points
ID: 33557189
my bad, actually Ping is not performed with TIdEcho but with TIdIcmpClient

function CheckInternet:Boolean;
begin
 Result:=False;
 With TIdIPWatch.Create(nil) do
  try
   if ForceCheck Then
    begin
     with TIdIcmpClient.Create(nil) do
      try
       Host := 'www.google.com';
       ReceiveTimeout:=999; //TimeOut du ping
       Ping();
       Result := True;
      finally
       Free;
      end;
     if Not Result Then ShowMessage('Google not available !');
    end Else ShowMessage('No IP address');
  finally
   Free;
  end
end;

Open in new window

0
 
LVL 14

Expert Comment

by:systan
ID: 33557215
rfwoolf;
CodedK has the best answer.
But how long would you closed all your open post?
I have seen several question answered from delphi experts.
I'm sorry if I offended you,  but,  that is not good,  throwing some points to the experts who participated in your post is one great help.
0
 
LVL 12

Accepted Solution

by:
Hypo earned 500 total points
ID: 33557638
There is actually a win-api function to check for internet connection called "InternetCheckConnection".
It is located in the wininet unit.

According to the help it supports the following OS: Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Me, Windows 98, or Windows 95.

/Hypo
uses ..., wininet;

...

procedure TForm3.Button1Click(Sender: TObject);
const FLAG_ICC_FORCE_CONNECTION = 1;
begin
  if InternetCheckConnection('http://www.google.com', FLAG_ICC_FORCE_CONNECTION, 0)
    then ShowMessage('Connected')
    else ShowMessage('Not connected');
end;

Open in new window

0
 
LVL 25

Expert Comment

by:epasquier
ID: 33559635
Yes of course ! InternetCheckConnection ! I forgot about that one...

Thanks Hypo ! And it's good to hear from you again !
0
 
LVL 14

Expert Comment

by:systan
ID: 33559787
Welcome back Hypo;
I'm glad to hear you.

Before I post my first comment,  I'm thinking to post "InternetCheckConnection" but probably ping is the best and quickiest way to find out, because you can customized the byte to send, you can send 1 byte n reply.
0
 
LVL 12

Expert Comment

by:Hypo
ID: 33566678
Thanks :) It's good to be back again... I've been way too busy with other projects for quite some time now, but I'll try to look in here more often :D

/Hypo
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

636 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