Conexão

Delphi

26/05/2003

Olá,

Como posso detectar o início e o término de uma conexão com a Internet, existe alguma função específica para isso?

Grato pela atenção.


Marcos
mark@smo.com.br


Atomix

Atomix

Curtidas 0

Respostas

Celo-faveri

Celo-faveri

26/05/2003

Brother...você pode usar a seguinte função:

function RemoteConnection: boolean;
const
Key = ´\System\CurrentControlSet\Services\RemoteAccess´;
Value = ´Remote Connection´;
var
Reg: TRegistry;
Buffer: DWord;
begin
Result := false;

Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey(Key, false) then
begin
Reg.ReadBinaryData(Value, Buffer, SizeOf(Buffer));
Result := Buffer = 1;
end;
finally
Reg.CloseKey;
Reg.Free;
end;
end;

Exemplo de uso

Para testar a função coloquei um Timer e um Label no
formulário. No evento OnTimer, do Timer, escrevi o
código abaixo.

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if RemoteConnection() then
Label1.Caption := ´Conectado´
else
Label1.Caption := ´Desconectado´;
end;

Bem...só testei com conexão discada...com conexão de banda larga ainda não testei...

Valew
T+


GOSTEI 0
POSTAR