我如何才能知道用户是否已连接到互联网? [英] how can i realize if the user is connected to the internet or not?
本文介绍了我如何才能知道用户是否已连接到互联网?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是的,我知道! www.codeproject.com中存在很多相同的问题.但是我需要一个标准的API或一些东西来检测连通性.
yes I know! there is a lot of the same question here in www.codeproject.com. But I need a standard API or something to detect the connectivity.
推荐答案
您可以通过包含wininet.h并使用以下代码段来使用InternetGetConnectedState():
You can use InternetGetConnectedState() by including wininet.h and using the following snippet:
<br />#pragma comment(lib,"wininet.lib")<br /> <br />if (InternetGetConnectedState(INTERNET_CONNECTION_LAN | INTERNET_CONNECTION_MODEM,0) == FALSE)<br />{<br /> // Not connected!<br />}<br />else<br />{<br /> // Connected!<br />}<br />
干杯! :)
Cheers! :)
请参见此处.
See here.
查看IsNetworkAlive
API
Check out theIsNetworkAlive
API
这篇关于我如何才能知道用户是否已连接到互联网?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文