Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internet connection: detect online and being able to kill it 2

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
Hi guys,

How can I detect wether or not a computer is online and kill
the connection when the user presses a button ???

Thank you, [bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
A place where I could download components for it would also
be great, I already tried Delphi32.com and Torry.net [bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Not all connections can be killed. What about those of us with cable modems? You can't just hang up one of those.
 
But I could close the ports so no data transport is possible. But I want to know how I can kill a 56k modem
for example, or ISDN or xDSL. Isnt there an API for that
or did I just plainly miss it ??? [bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
This function checks if there is a valid internet connection. You need to add Wininet to your uses list.

Andrew

uses Wininet;

function ConnectedToInternet: boolean;
// Returns TRUE if a valid internet connection is available
var
connect_status: LongWord;
begin
connect_status := 2 {lan} + 1 {modem} + 4 {proxy};
result := InternetGetConnectedState ( @connect_status,0 );
end;

 
Closing the ports will clobber any ongoing transfers but will not prevent new connections from being opened. A 56k modem could be hung up (look for a RAS component) but an awful lot of people these days have connections that have no way to hang up. The only way to turn them off would be to leave a program running that stopped all transfers. I know it's possible (look at firewall software) but I have no idea how to do it.
 
You could use the following function for detecting the kind of connection

function ConnectionKind: Boolean;
var
flags: DWORD;
Code:
begin
  Result := InternetGetConnectedState(@flags, 0);
  if Result then
  begin
    if (flags and INTERNET_CONNECTION_MODEM) =    
        INTERNET_CONNECTION_MODEM
        then ShowMessage('Modem');
    if (flags and INTERNET_CONNECTION_LAN) = 
        INTERNET_CONNECTION_LAN 
        then ShowMessage('LAN');
    if (flags and INTERNET_CONNECTION_PROXY) =  
        INTERNET_CONNECTION_PROXY
        then ShowMessage('Proxy');
    if (flags and INTERNET_CONNECTION_MODEM_BUSY) =
        INTERNET_CONNECTION_MODEM_BUSY then
        ShowMessage('Modem Busy');
  end;
end;

Regards Steven van Els
SAvanEls@cq-link.sr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top