InternetGetConnectedState

#include <Wininet.h> #pragma comment(lib, "Wininet.lib") DWORD GetInternetConnectedState() { DWORD dwFlags = 0; if( InternetGetConnectedState( &dwFlags, 0) ) { #ifndef INTERNET_CONNECTION_CONFIGURED #define INTERNET_CONNECTION_CONFIGURED 0x40UL #endif #ifndef INTERNET_CONNECTION_OFFLINE #define INTERNET_CONNECTION_OFFLINE 0x20UL #endif #ifndef NET_TYPE_RAS_INSTALL #define NET_TYPE_RAS_INSTALL 0x10 //RAS安装 #endif #define DBGMACRO(x) { if(dwFlags &(x)) TRACE(_T("dwFlags=%s/n"), #x); } DBGMACRO(INTERNET_CONNECTION_CONFIGURED);//0x40 //Local system has a valid connection to the Internet, but it might or might not be currently connected. DBGMACRO(INTERNET_CONNECTION_LAN);//0x02 //Local system uses a local area network to connect to the Internet. DBGMACRO(INTERNET_CONNECTION_MODEM); //0x01 //Local system uses a modem to connect to the Internet. DBGMACRO(INTERNET_CONNECTION_MODEM_BUSY);//0x08 //No longer used. DBGMACRO(NET_TYPE_RAS_INSTALL); //0x10 //RAS安装 DBGMACRO(INTERNET_CONNECTION_OFFLINE);//0x20 //Local system is in offline mode. DBGMACRO(INTERNET_CONNECTION_PROXY);//0x04 //Local system uses a proxy server to connect to the Internet. } else { TRACE( _T("InternetGetConnectedState Err=%d"), GetLastError() ); } return dwFlags; }

你可能感兴趣的:(InternetGetConnectedState)