Created
January 25, 2016 17:46
-
-
Save evandroamparo/80c1b79337b575eda1de to your computer and use it in GitHub Desktop.
Detect network connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit unet; | |
interface | |
uses | |
Windows; | |
const | |
NETWORK_ALIVE_LAN = $1; | |
NETWORK_ALIVE_WAN = $2; | |
NETWORK_ALIVE_AOL = $4; | |
type | |
tagQOCINFO = record | |
dwSize: DWORD; | |
dwFlags: DWORD; | |
dwInSpeed: DWORD; | |
dwOutSpeed: DWORD; | |
end; | |
{$EXTERNALSYM tagQOCINFO} | |
QOCINFO = ^tagQOCINFO; | |
{$EXTERNALSYM QOCINFO} | |
LPQOCINFO = ^QOCINFO; | |
{$EXTERNALSYM LPQOCINFO} | |
// TQocInfo = QOCINFO; | |
// PQocInfo = LPQOCINFO; | |
function IsDestinationReachableA(lpszDestination: LPCSTR; lpQOCInfo: QOCINFO): BOOL; stdcall; | |
{$EXTERNALSYM IsDestinationReachableA} | |
function IsDestinationReachableW(lpszDestination: LPCWSTR; lpQOCInfo: QOCINFO): BOOL; stdcall; | |
{$EXTERNALSYM IsDestinationReachableW} | |
function IsDestinationReachable(lpszDestination: LPCTSTR; lpQOCInfo: QOCINFO): BOOL; stdcall; | |
{$EXTERNALSYM IsDestinationReachable} | |
function IsNetworkAlive(out lpdwFlags: DWORD): BOOL; stdcall; | |
{$EXTERNALSYM IsNetworkAlive} | |
implementation | |
function IsNetworkAlive(out lpdwFlags: DWORD): BOOL; stdcall; | |
external 'sensapi.dll' name 'IsNetworkAlive'; | |
function IsDestinationReachableA(lpszDestination: LPCSTR; lpQOCInfo: QOCINFO): BOOL; stdcall; | |
external 'sensapi.dll' name 'IsDestinationReachableA'; | |
function IsDestinationReachableW(lpszDestination: LPCWSTR; lpQOCInfo: QOCINFO): BOOL; stdcall; | |
external 'sensapi.dll' name 'IsDestinationReachableW'; | |
function IsDestinationReachable(lpszDestination: LPCTSTR; lpQOCInfo: QOCINFO): BOOL; stdcall; | |
external 'sensapi.dll' name 'IsDestinationReachable'; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment