Dial Internet default connection  

Send By: Feņiz
Web : N.A.
Email: feniz@ono.com
Date: 23/04/03

Tip accessed 475 times

 


To dial Internet default connection, we can use the function:

 InternetAutodial (INTERNET_AUTODIAL_FORCE_ONLINE or
 INTERNET_AUTODIAL_FORCE_UNATTENDED, 0)



And to hang up the active connection:

 InternetAutodialHangup (0);



Both cases, we must include WinInet at the uses of the active form.

Both functions return TRUE if action was successfully, or FALSE if not.

If we want also to check if the computer is already connected to Internet, we can do it using the function InternetGetConnectdState.

Let's go to use it in an example. We'll made a function to check if we are connected to Internet or not. If we are, it will hang up connection. If not, it will connect.

 var dwTiposConexion: DWORD;

 begin
 dwTiposConexion := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN +
 INTERNET_CONNECTION_PROXY;

 if (InternetGetConnectedState(@dwTiposConexion, 0)) then  //Como ya estamos
 conectados a Internet, nos desconectamos
     InternetAutodialHangup (0);

 else   //Como no estamos conectados a Internet, nos conectamos
     InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE or
 INTERNET_AUTODIAL_FORCE_UNATTENDED, 0)
 end;