Delphi .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Detect a RAS connection to the internet
This article has not been rated yet. After reading, feel free to leave comments and rate it.
The following code is a possibility to detect a connection to the internet,
altough it is not 100%.
I have tested it on Windows NT with LAN connections (DSL and cable)
and it worked in these cases.
 | |  | | const
INTERNET_CONNECTION_MODEM = 1;
INTERNET_CONNECTION_LAN = 2;
INTERNET_CONNECTION_PROXY = 4;
INTERNET_CONNECTION_MODEM_BUSY = 8;
function InternetGetConnectedState(lpdwFlags: LPDWORD;
dwReserved: DWORD): BOOL; stdcall; external 'WININET.DLL';
function _IsConnectedToInternet: Boolean;
var
dwConnectionTypes: Integer;
begin
try
dwConnectionTypes := INTERNET_CONNECTION_MODEM +
INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
if InternetGetConnectedState(@dwConnectionTypes, 0) then
Result := true
else
Result := false;
except
Result := false;
end;
end;
| |  | |  |
Comments:
|