home
clear breadcrumbs
search
login
 
internet connectivity logging
#include
#include
#include
#include
#pragma comment(lib,"Wininet.lib") #pragma warning(disable : 4996) using namespace std; void main() { LPCWSTR url = L"https://google.com"; ofstream logFile; char answer{}; cout << "Close the window to quit" << endl; while (true) { time_t now = time(0); char* dt = ctime(&now); bool bConnect = InternetCheckConnection(url, FLAG_ICC_FORCE_CONNECTION, 0); logFile.open("connectivityLog.txt", std::ios_base::app); if (!bConnect) { logFile << "internet connection test failed on " << dt; // output to log file cout << "internet connection test failed on " << dt << endl; // output to console } logFile.close(); Sleep(60000); // wait 60 seconds between tests } }