0% found this document useful (0 votes)
2K views1 page

Create VPN Connection With Delphi

This document contains code to check if a system has an active internet connection. It uses the WinInet library functions InternetGetConnectedState, InternetOpen, and InternetOpenURL to check the system's connection state and attempt to connect to a URL. If the system is configured for a connection but a connection attempt fails, or the system reports being offline, it returns false. Otherwise it returns true to indicate an active internet connection.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views1 page

Create VPN Connection With Delphi

This document contains code to check if a system has an active internet connection. It uses the WinInet library functions InternetGetConnectedState, InternetOpen, and InternetOpenURL to check the system's connection state and attempt to connect to a URL. If the system is configured for a connection but a connection attempt fails, or the system reports being offline, it returns false. Otherwise it returns true to indicate an active internet connection.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

uses WinInet; function TForm1.

IsConnected: Boolean; const // Local system has a valid connection to the Internet, but it might or might // not be currently connected. INTERNET_CONNECTION_CONFIGURED = $40; // Local system uses a local area network to connect to the Internet. INTERNET_CONNECTION_LAN = $02; // Local system uses a modem to connect to the Internet INTERNET_CONNECTION_MODEM = $01; // Local system is in offline mode. INTERNET_CONNECTION_OFFLINE = $20; // Local system uses a proxy server to connect to the Internet INTERNET_CONNECTION_PROXY = $04; // Local system has RAS installed. INTERNET_RAS_INSTALLED = $10; var InetState: DWORD; hHttpSession, hReqUrl: HInternet; begin Result := InternetGetConnectedState(@InetState, 0); if (Result and (InetState and INTERNET_CONNECTION_CONFIGURED = INTERNET_CONNEC TION_CONFIGURED) ) then begin // so far we ONLY know there's a valid connection. See if we can grab some k nown URL ... hHttpSession := InternetOpen( PChar(Application.Title), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try hReqUrl := InternetOpenURL(hHttpSession, 'http://www.google.com', nil, 0,0 ,0); Result := hReqUrl <> nil; InternetCloseHandle(hReqUrl); finally InternetCloseHandle(hHttpSession); end; end else if (InetState and INTERNET_CONNECTION_OFFLINE = INTERNET_CONNECTION_OFFLINE) then Result := False; // we know for sure we are offline. end;

You might also like