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?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
http://msdn.microsoft.com/en-us/library/aa370750(VS.85).aspx describes the difference between
IsConnected
andIsConnectedToInternet
. Windows 7 only. I don't have a native code sample handy, sorry.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.
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.
The Windows API Code Pack will do this for you http://archive.msdn.microsoft.com/WindowsAPICodePack
its NetworkListManager Class has an IsConnected property that indicates if you have LAN connection
and an IsConnectedToInternet property that indicates if you have Internet connection
the pack download contains a Network Demo application that demonstrates this
Pinging
4.2.2.2
is a common means of determining if internet connectivity is present.The story behind this lies here.