Is there anyway with Windows api to detect whether a Windows 7 computer's network connection is an internet connection or a LAN connection without internet access? Windows 7 and Vista indicate this in the network icon (Local only v. Local and Internet), is there anyway to grab that information progammatically?
                
                A: 
                
                
              Not perfectly.
You could detect if you are on a lan from the IP address (assuming your local DHCP handed out one of the 192.168.xx.xx private addresses.)
YOu could ping a known external site to check if that lan has an internet connection.
                  Martin Beckett
                   2010-04-20 18:41:47
                
              Just because the computer has a private IP address (which also include 10.x.x.x and 172.16-31.x.x) doesn't mean it's not connected to the Internet. As anyone accessing this site from behind a home router performing NAT can attest!
                  Stephen C. Steel
                   2010-04-20 19:20:07
                It wasn't clear what the OP was asking ie. direct internet connection vs NAT
                  Martin Beckett
                   2010-04-20 21:17:04
                
                +1 
                A: 
                
                
              Pinging 4.2.2.2 is a common means of determining if internet connectivity is present.
The story behind this lies here.
                  Adam Robinson
                   2010-04-20 18:45:44
                
              Although now 8.8.8.8 is probably better (behold the might of google)
                  Martin Beckett
                   2010-04-20 18:55:06
                @Martin: Yes, though 4.2.2.2 is now muscle memory for me. I don't know if I can bear to learn 8.8.8.8 and its uncomfortable angle between index- and middle finger.
                  Adam Robinson
                   2010-04-20 18:56:30
                
                +2 
                A: 
                
                
              http://msdn.microsoft.com/en-us/library/aa370750(VS.85).aspx describes the difference between IsConnected and IsConnectedToInternet. Windows 7 only. I don't have a native code sample handy, sorry. 
                  Kate Gregory
                   2010-04-20 19:02:48
                
              
                
                A: 
                
                
              
            Windows 7 performs DNS query for dns.msftncsi.com 5 seconds after link establishment. Do not see any reason to do that except for checking internet connection.
                  Eakraly
                   2010-04-21 21:45:52