Checking for Internet connection can be done using this code:
#include <wininet.h>
#pragma comment(lib,"Wininet.lib")
bool bConnect=InternetCheckConnection(L"http://www.google.com",
FLAG_ICC_FORCE_CONNECTION ,0);
A return value of true means Internet connection is available.