Ncsi is a project mainly written in ..., it's free.
Network Connectivity Status Indicator
Detect whether the computer has internet access, as described at: http://blog.superuser.com/2011/05/16/windows-7-network-awareness/ http://technet.microsoft.com/en-us/library/cc766017(WS.10).aspx
Return code is:
0 - Connection is working 1 - DNS is working, but web traffic is not working: there may be a log-on page 2 - DNS is not working: there is a problem with the connection