// Процедура для разрыва связи с интернетом ------------------------------------
procedure DisconnectNow;
var
Lib: HINST;
RasEnumConnections: TRasEnumConnections;
RasHangUp: TRasHangUp;
RasConn: TRasConn;
SizeC: DWORD;
begin
try
Lib := LoadLibrary('rasapi32.dll');
try
if Lib = 0 then Abort;
RasEnumConnections := GetProcAddress(Lib, 'RasEnumConnectionsA');
if not Assigned(@RasEnumConnections) then Abort;
RasHangUp := GetProcAddress(Lib, 'RasHangUpA');
if not Assigned(@RasHangUp) then Abort;
FillChar(RasConn, SizeOf(RasConn), 0);
RasConn.SizeC := SizeOf(RasConn);
Code := RasEnumConnections(RasConn, SizeC, Connections);
if (Connections <> 1) or (Code <> 0) then Abort;
if RasHangUp(RasConn.Handle) <> 0 then Abort;
Sleep(3000);
finally
FreeLibrary(Lib);
end;
except
on E: EAbort do
ShowMessage('Не могу разорвать связь с интернетом!');
else
raise;
end;
end;
//==============================================================================
procedure TForm1.Button1Click(Sender: TObject);
begin
DisconnectNow;
end;
end.