#include <iostream> #include <WTypes.h> #include <Sensapi.h> using namespace std; #pragma comment(lib,"Sensapi.lib") bool isConnect() { DWORD dwFlags; if(IsNetworkAlive(&dwFlags)) { if(NETWORK_ALIVE_LAN == dwFlags) { cout<<"One or more LAN"<<endl; } else if(NETWORK_ALIVE_WAN == dwFlags) { cout<<"One or more RAS"<<endl; } else { } return true; } else { DWORD dwError = GetLastError(); if(ERROR_SUCCESS == dwError) { cout<<"No Connection"<<endl; } else { cout<<"Connection Error"<<endl; } return false; } } void main(int argc,TCHAR*argv[]) { isConnect(); }