procedure TMainForm.ConnectButtonClick(Sender: TObject);
var d: DWORD;
begin
d := INTERNET_CONNECTION_MODEM
or INTERNET_CONNECTION_LAN
or INTERNET_CONNECTION_PROXY;
if InternetGetConnectedState(@d, 0)
or InternetAutoDial(INTERNET_AUTODIAL_FORCE_UNATTENDED,
handle)
then begin
ConnectButton.Enabled := False;
DisconnectButton.Enabled := True;
Color := clLime;
end;
end;
procedure TMainForm.DisconnectButtonClick(Sender: TObject);
var d: DWORD;
begin
d := INTERNET_CONNECTION_MODEM
or INTERNET_CONNECTION_LAN
or INTERNET_CONNECTION_PROXY;
if (
not InternetGetConnectedState(@d, 0))
or InternetAutoDialHangup(0)
then begin
ConnectButton.Enabled := True;
DisconnectButton.Enabled := False;
Color := clRed;
end;
end;