Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Oct : Re: Checking for Internet connection

www.cryer.info
Managed Newsgroup Archive

Re: Checking for Internet connection

Subject:Re: Checking for Internet connection
Posted by:"Mark Kimball" (makimba..@hotmail.com)
Date:11 Oct 2007 06:24:48

To those who requested the solution I finally found, here is the
code I am using to determine if the computer has a current
connection to the Internet.  Please note that it requires the
WinInet unit in the Uses clause.

// requires WinInet in the Uses clause

function TYourApp.ConnectedToInternet : Boolean;
var
  dwConnection: DWORD;
begin
  dwConnection := INTERNET_CONNECTION_MODEM +
      INTERNET_CONNECTION_LAN + INTERNET_CONNECTION_PROXY;

  try
    Result := InternetGetConnectedState(@dwConnection, 0);
  except
    Result := False;
  end;

end;

Replies:

www.cryer.info
Managed Newsgroup Archive