04‏/02‏/2013

How to check internet connection using delphi

How to check internet connection using delphi!!


Hello every one , in this topic I'll represente to you the Function responsible for making sure your internet connection.

First : 

You have to use those library in delphi :  ( WIndows , WinInet )

Go to the uses section code and type :

uses
   Windows,WinInet;

Second :

And then go to the Implementation section and type this function :

function checkInternet(): boolean;
 var
  dwFlags : DWORD;
begin

  dwFlags :=INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN
           + INTERNET_CONNECTION_PROXY ;
  RESULT := InternetGetConnectedState(@dwFlags,0);
end;


How Can I  use this ?

with a simple call .....
checkInternet()
  the function retrun 1 if connection 
else return 0 if disconnection
Thank you. 




0 commentaires:

إرسال تعليق