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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internet Connection awareness

Status
Not open for further replies.

cyberant

Programmer
Sep 21, 2003
44
ZA
Is there a way that I can be aware of an internet connection through delphi code?
 
Sorry can't seem to see anything in the FAQ. Checked the references as well.
 
Here's the code I used:

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

It returns a boolean saying whether it's connected and the ConType parameter which gives you the type
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top