How to check if local system is connected to a network and identify the type of network connection
Posted by Karthick P.K on July 26, 2010
#include <windows.h> #include <iostream> using namespace std; #pragma comment(lib, "Sensapi.lib") #include <Sensapi.h> void main() { bool a; LPDWORD lpdwFlags; lpdwFlags = new DWORD; a=IsNetworkAlive( lpdwFlags); if(GetLastError()!=0) { cout<<"IsNetworkAlive failed:%d"<<GetLastError(); } else if(GetLastError()==0 & (!a) ) { cout<<"Network is not connected"; } else if(GetLastError()==0 & (a)) { cout<<"Network is connected.Type: "<< *lpdwFlags; //1=Lan and 2=WAN } }
Regards
Karthick P.K
Balaji said
How and where to execute it ?
Top SQL Server blogs from MSSQLWIKI « MSSQLWIKI said
[…] How to check if local system is connected to a network and identify the type of network connection […]