通过Visual C ++应用程序测试系统上的Internet连接 [英] Test the internet connection on the system through visual c++ application

查看:78
本文介绍了通过Visual C ++应用程序测试系统上的Internet连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我的系统是否已连接到网络,并且我正在Visual C ++ 6.0中工作.我如何通过可视C ++应用程序检测网络?我也需要相同的代码.

I want to know my system is connected to a network or not and I am working in visual c++ 6.0. How could i detect a network through a visual c++ application ???? I also need the codes for same.

推荐答案

此链接可能会有所帮助:-

http://social.msdn.microsoft.com/Forums/zh/vcgeneral/thread/ea29ed9e-9506-4fd5-9f69-b348a6e5ebdf [
This link might be helpful:-

http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/ea29ed9e-9506-4fd5-9f69-b348a6e5ebdf[^]

Mark this as your answer if it helps you out or else response with query


使用InternetGetConnectedState() [ ^ ](这可能会显示拨号对话框).

您也可以使用InternetCheckConnection(),但是这会使用ping命令,如果在到主机URL的路由上某处阻止了ICMP回显请求(ping),则ping可能会失败.
Use InternetGetConnectedState() [^] to get the state. When configured and offline, you may connect using InternetAttemptConnect(0) [^] (this may show the dial-up dialog).

You may also use InternetCheckConnection(), but this uses pings which may fail if ICMP echo request (pings) are blocked somewhere on the route to the host URL.


#include "Wininet.h"
bool bstate= InternetGetConnectedState(&dwFlags,0);



bstate 显示0或1的情况下有效,其中0表示没有连接,否则1表示具有互联网连接.



This works where bstate shows 0 or 1 where 0 is no connection else 1 is with internet connection.


这篇关于通过Visual C ++应用程序测试系统上的Internet连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆