I've heard that the Win32 API function InternetGetConnectedState () isn't always reliable, but I don't think anything is, oddly enough. Anyway, if the Online () function below returns True, you're theoretically online...
[EDIT: Oops, Win32 only... not progressed to other OSes' API calls yet!]
[EDIT: Oops, Win32 only... not progressed to other OSes' API calls yet!]
' Function pointer... Global Online (flagsptr:Int Ptr, reserved) ' Win32 constants... Const INTERNET_CONNECTION_CONFIGURED = $40 Const INTERNET_CONNECTION_LAN = $02 Const INTERNET_CONNECTION_MODEM = $01 Const INTERNET_CONNECTION_MODEM_BUSY = $08 Const INTERNET_CONNECTION_OFFLINE = $20 Const INTERNET_CONNECTION_PROXY = $04 Const INTERNET_RAS_INSTALLED = $10 ' Load wininet.dll and assign function pointer... wnet = LoadLibraryA ("wininet.dll") If wnet Online = GetProcAddress (wnet, "InternetGetConnectedState") EndIf ' Flags integer receives details of connection... Local flags = 0 ' Call function... result = Online (Varptr (flags), 0) ' Show results... If result Print "" Print "Connection found!" Print "" If flags & INTERNET_CONNECTION_CONFIGURED Print "Valid connection found" EndIf If flags & INTERNET_CONNECTION_LAN Print "LAN-based connection to internet" EndIf If flags & INTERNET_CONNECTION_MODEM Print "Modem-based connection to internet" EndIf If flags & INTERNET_CONNECTION_MODEM_BUSY Print "No longer used" EndIf If flags & INTERNET_CONNECTION_OFFLINE Print "Currently offline" EndIf If flags & INTERNET_CONNECTION_PROXY Print "Proxy connection to internet" EndIf If flags & INTERNET_RAS_INSTALLED Print "RAS installed" EndIf Else Print "Not connected!" EndIf