Conexão
26/05/2003
0
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
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
Curtir tópico
+ 0
Responder
Posts
15/11/2003
Celo-faveri
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+
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+
Responder
Clique aqui para fazer login e interagir na Comunidade :)