Board index » delphi » Net Detect?

Net Detect?

Can someone point me to a component or information on how to program an
application to detect when the computer is connected to the internet.
(Similar to ICQ). I would like the application to run on startup (which I
can do I think) and for it to do things in the background when connected to
the net.

Thanks

Sean

 

Re:Net Detect?


You can check if a RAS dial is in use by using the RasGetConnections API.
The RAS header file translated can be found on several Delphi pages like
Torry's Delphi Pages and The Delphi Super Page.

Torry's Delphi Page - http://www.torry.ru

--

Janus N. T?ndering
Email: janusnt<alpha>usa<dot>net
Please correct my email address if you
want to mail me....thanks

Quote
Sean Douglas wrote in message <01bd8f69$a315e0e0$20020ccb@default>...
>Can someone point me to a component or information on how to program an
>application to detect when the computer is connected to the internet.
>(Similar to ICQ). I would like the application to run on startup (which I
>can do I think) and for it to do things in the background when connected to
>the net.

>Thanks

>Sean

Re:Net Detect?


Well, Janus, this won't help if you are connected via LAN. To be sure that
you DETECT connectio, use this procedure.

{ This is easier then working with RasEnumConnections!!! }

Function GetRasStatus:Longint;   { get number of RAS connections }
var
MyRegistry:TRegistry;
begin
{ Change registry to load every time }
MyRegistry:=TRegistry.Create;
With MyRegistry do
begin
RootKey:=HKEY_LOCAL_MACHINE;
OpenKey('System\CurrentControlSet\Services\RemoteAccess',True);
ReadBinaryData('Remote Connection',Result,SizeOf(Result));
CloseKey;
end;
MyRegistry.Free;
end;

Function DetectConnection:Boolean;
var
IPList:TStrings;
begin
IPList:=LocalIPList;
Result:=IPList.Count<>0;
If GetRasStatus>0 then Result:=True;
end;

Butt:
What happens if you already have a TCP/IP stack loaded on the machine?
Before you connect you will have a local IP address.  Then when you connect
your machine->internet will get an ip address and then on...???

I dunno solution for this.  :-( Though, my solution works pretty well in 98%
cases.

Janus N?rgaard T?ndering usa net> D??? ???Y??
<3576eb9...@news.euroconnect.dk> ...

Quote
>You can check if a RAS dial is in use by using the RasGetConnections API.
>The RAS header file translated can be found on several Delphi pages like
>Torry's Delphi Pages and The Delphi Super Page.

>Torry's Delphi Page - http://www.torry.ru

>--

>Janus N. T?ndering
>Email: janusnt<alpha>usa<dot>net
>Please correct my email address if you
>want to mail me....thanks

>Sean Douglas wrote in message <01bd8f69$a315e0e0$20020ccb@default>...
>>Can someone point me to a component or information on how to program an
>>application to detect when the computer is connected to the internet.
>>(Similar to ICQ). I would like the application to run on startup (which I
>>can do I think) and for it to do things in the background when connected
to
>>the net.

>>Thanks

>>Sean

Other Threads