Checar o tipo de conexão com a Internet
Declare a uses: Wininet. Declare uma função com a seguinte instrução:
function ConnectionKind: Boolean;
var
flags: DWORD;
begin
Result := InternetGetConnectedState(@flags, 0);
if Result then
begin
if (flags and INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM then
ShowMessage('Modem');
if (flags and INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN then
ShowMessage('LAN');
if (flags and INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY then
ShowMessage('Proxy');
if (flags and INTERNET_CONNECTION_MODEM_BUSY) = INTERNET_CONNECTION_MODEM_BUSY then
ShowMessage('Modem Busy');
end;
end;
Em um botão coloque o seguinte código:
procedure TForm1.Button1Click(Sender: TObject);
begin
ConnectionKind;
end;
Veja o exemplo em ação:
Figura 1. O exemplo em ação!