Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

How to tell the type of internet connection your pc is connected to

{ You must be connected to the internet and don't forget to add this unit to get it to work :-) } uses wininet; function KindOfConnection :boolean; var flags: dword; begin Result := InternetGetConnectedState(@flags, 0); if Result then begin if (flags and INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM then begin showmessage('Modem'); end; if (flags and INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN then begin showmessage('LAN'); end; if (flags and INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY then begin showmessage('Proxy'); end; if (flags and INTERNET_CONNECTION_MODEM_BUSY)=INTERNET_CONNECTION_MODEM_BUSY then begin showmessage('Modem Busy'); end; end; end; procedure TForm1.Button1Click(Sender: TObject); begin KindOfConnection; end;