Programmatically check whether my machine has internet access or not
问题 How can I programmatically check whether my machine has internet access or not using C/C++, is it just a matter of pinging an IP? How does NIC do it ? I mean something like: I am using Windows 7. 回答1: If you work on Windows, just try this #include <iostream> #include <windows.h> #include <wininet.h> using namespace std; int main(){ if(InternetCheckConnection(L"http://www.google.com",FLAG_ICC_FORCE_CONNECTION,0)) { cout << "connected to internet"; } return 0; } 回答2: There is nothing of that