InternetCheckConnection 通过尝试连接特定的网址,可以用来判断目前机器是否接通外网。例如:

BOOL bConnected = InternetCheckConnection(_T("http://www.google.com"), FLAG_ICC_FORCE_CONNECTION, 0);

使用时第二个参数一定要设置为FLAG_ICC_FORCE_CONNECTION,这样才会尝试去建立连接。当目标地址不可用时,这个函数返回会比较慢,注意不要在UI线程中使用。

这个函数会解析出URL中的host地址,然后建立socket连接去ping这个地址。

InternetCheckConnection

Allows an application to check if a connection to the Internet can be established.

<strong>BOOL InternetCheckConnection(LPCTSTR</strong> <em><a target=_blank class="synParam" href="http://blog.csdn.net/harbinzju/article/details/6956814" style="color: rgb(202, 0, 0); text-decoration: none;">lpszUrl</a></em><strong>,DWORD</strong> <em><a target=_blank class="synParam" href="http://blog.csdn.net/harbinzju/article/details/6956814" style="color: rgb(202, 0, 0); text-decoration: none;">dwFlags</a></em><strong>,DWORD</strong> <em><a target=_blank class="synParam" href="http://blog.csdn.net/harbinzju/article/details/6956814" style="color: rgb(202, 0, 0); text-decoration: none;">dwReserved</a></em><strong>
);</strong>

Parameters

lpszUrl
[in] Pointer to a null-terminated string that specifies the URL to use to check the connection. This value can be NULL.
dwFlags
[in] Options. FLAG_ICC_FORCE_CONNECTION is the only flag that is currently available. If this flag is set, it forces a connection. A sockets connection is attempted in the following order:

  • If lpszUrl is non-NULL, the host value is extracted from it and used to ping that specific host.
  • If lpszUrl is NULL and there is an entry in the internal server database for the nearest server, the host value is extracted from the entry and used to ping that server.
dwReserved
[in] Reserved. Must be zero.

Return Values

Returns  TRUE  if a connection is made successfully, or  FALSE  otherwise. Use  GetLastError  to retrieve the error code. ERROR_NOT_CONNECTED is returned by  GetLastError  if a connection cannot be made or if the sockets database is unconditionally offline.

InternetCheckConnection 通过尝试连接特定的网址,可以用来判断目前机器是否接通外网相关推荐

  1. 实现外网远程连接服务器:Natapp使用教程

    前言: 实验室的服务器只能在内网访问,在外面就不能连接服务器,非常不方便,于是想通过外网穿透的方式,在不连接实验室局域网的情况下连接到实验室的服务器. 本人用的natapp软件,亲测可用,其实nata ...

  2. 远程桌面连接的开启,和借助内外网软件,实现外网PC手机远程控制内网电脑,详细图文教程

    简要:远程桌面的配置使用,利用teamviewer和nat123等工具外网远程访问内网,及手机外网控制内网桌面. 在实际环境操作中,大多人会遇到这样的问题:主机在内网,需要开启远程桌面,并同时需要提供 ...

  3. 外网远程桌面连接内网服务器

    通用管理后台推荐 (兮家 plus) [兮家 plus], 主要应用于中小型项目的快速开发,已经历历时3年的优化改进,具备完善的基础功能以及代码生成,并且拥有完善的分布式解决方案:如分布式缓存,分布式 ...

  4. win10虚拟机怎么连接服务器,Win10系统虚拟机尝试连接到服务器出错怎么办

    很多用户都会在win10系统中使用虚拟机功能,而在使用的时候有用户却提示"虚拟机尝试连接到服务器'XXX'时出错,请检查虚拟管理服务是否正在运行以及是不授权你连接到此服务器"的错误 ...

  5. 尝试连接到服务器时出错请检查虚拟机管理器,Hyper-V尝试连接到服务器出错无效类的解决方法...

    Hyper-V尝试连接到服务器出错无效类的解决方法 Windows10安装Hyper-V后没有自动连接到本地计算机,手工连接失败,提示: 引用内容 尝试连接到服务器"DESKTOP-6P9L ...

  6. c# 再次尝试 连接失败_手机投屏电视连接不上怎么回事?

    现在的智能设备功能越来越多了,以家庭用户为单位,很多设备功能都是可以共享的.但基于用户对使用设备的不了解,在使用过程中会遇到很多解决不了的问题.本期文章就说说"手机投屏电视"连接不 ...

  7. 无法连接虚拟设备 ide1:0,因为主机上没有相应的设备。 您要在每次开启此虚拟机时都尝试连接此虚拟设备吗?

    问题 无法连接虚拟设备 ide1:0,因为主机上没有相应的设备. 您要在每次开启此虚拟机时都尝试连接此虚拟设备吗? 解决方法 原因: 是因为没设置使用镜像文件. 设置 点击虚拟机,再点击左侧页面编辑虚 ...

  8. 出现 尝试连接“EAI_NONAME未提供,或不知道节点名或服务名”失败 解决办法

    先说下出现问题的原因,IP地址不在同一网关 我用的是VirtualBox虚拟机装的Ubuntu系统,想实现主机(Win10系统)和虚拟机下的Ubuntu系统相互传输文件,在wi10整了个FileZil ...

  9. 尝试连接“ECONNREFUSED - 连接被服务器拒绝”失败。

    使用FileZilla链接linux(虚拟机系统)总是报错:尝试连接"ECONNREFUSED - 连接被服务器拒绝"失败. 转载:https://blog.csdn.net/ma ...

最新文章

  1. Javascript学习------内部对象
  2. RN中布局样式的写法
  3. 领域驱动设计在互联网业务开发中的实践
  4. 关于0xFFFFFFFF和alpha,温故而知新
  5. 如何给Docker hub用户上传头像
  6. Java synchronized到底锁住的是什么?
  7. 开源不止,前进不息:2018 OpenInfra Days China 来了!
  8. TLS(Thread Local Storage)问题demo
  9. C# 生成随机数重复问题
  10. 正则爬取猫眼电影排行榜 待修改版
  11. [转载]使用Response.Filter过滤非法词汇
  12. Linux Cgroups详解(二)
  13. VB.NET视频打开方式
  14. java 子网掩码 位数_java实现子网掩码转换为网络标识位
  15. 2-3 /电脑屏幕录制神器!- Bandicam 满足您对录屏功能的所有幻想!
  16. mysql查询各专业人数_查询各专业的学生数。
  17. syntax error:unterminated quoted string
  18. 一只鸟就这样耍弄了一个人
  19. windows服务简介
  20. ABP VNext学习日记18

热门文章

  1. JQuery使用手册 转载
  2. 阿里云全站加速DCDN全面支持WebSocket协议
  3. 解析Node.js v6.9.5官方文档的第一个例子的知识点
  4. 多行查询结果合并sys_connect_by_path
  5. vi-vim :删除、撤销、恢复删除、复制删除
  6. Linux 下五个顶级的开源命令行 Shell
  7. 一本通【例4-10】最优布线问题
  8. js分享微信 ,微博 ,qq空间
  9. 【Luogu】P1607庙会班车Fair Shuttle(线段树+贪心)
  10. linux操作系统基础篇(四)