#include "stdafx.h"
#include "windows.h"
#include <Sensapi.h>
#include <iostream>
#include <Wininet.h>
#pragma comment(lib, "Sensapi.lib")
#pragma comment(lib, "Wininet.lib")
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
BOOL isConnect;
DWORD dw;
isConnect = ::IsNetworkAlive( &dw );
while (1)
{
if(isConnect)
cout << "IsNetworkAlive连接" <<endl;
else
cout << "IsNetworkAlive未连接" <<endl;
cout<< "---------------------------------" <<endl;
DWORD dw2;
BOOL ret = InternetGetConnectedState(&dw2, 0);
if (ret)
cout << "InternetGetConnectedState连接" <<endl;
else
cout << "InternetGetConnectedState未连接" <<endl;
cout<< "**********************************" <<endl;
BOOL bConnected = InternetCheckConnection(_T("http://www.baidu.com"), FLAG_ICC_FORCE_CONNECTION, 0);
if (bConnected)
cout << "InternetCheckConnection连接" <<endl;
else
cout << "InternetCheckConnection未连接" <<endl;
cout<< "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" <<endl;
//IsDestinationReachable(_T("http://www.google.com"), )
cout<<endl<<endl<<endl;
Sleep(1000);
}
getchar();
return 1;
}
vc 网络连接的测试方法
最新推荐文章于 2024-04-24 17:03:34 发布