How to check an Internet connection

简介:
Often in an App that works with Internet you need to know is user connected to Internet or not? I think below is most flexible sotution
To make sure in this point you need to import InetIsOffline function from URL.DLL: 

function InetIsOffline(Flag: Integer): Boolean; stdcall; external 'URL.DLL'; 

and then simply call this function in place you want to check connection status: 

if InetIsOffline(0) then 
   ShowMessage('This computer is not connected to Internet!') 
else 
   ShowMessage(You are connected to Internet!'); 

This function return TRUE if the local system isn't connected to Internet, or FALSE if it's connected or no attempt has been yet made to connect. 

Notes: 
Variable Flag is ignored, so always use zero. 
This DLL is usual installed on most computers. It is always installed on Win98 or comes with Internet Explorer 4 or later, Office 97 etc. 

Read more on MSDN. Original: http://msdn.microsoft.com/library/psdk/shellcc/shell/Functions/InetIsOffline.htm



    本文转自 OldHawk  博客园博客,原文链接:http://www.cnblogs.com/taobataoma/archive/2007/06/16/785627.html,如需转载请自行联系原作者



相关文章
|
4月前
|
Java 关系型数据库 MySQL
记录解决一个小错误:Establishing SSL connection without server‘s identity verification is not recommended
本文记录了解决Spring Boot连接MySQL时出现的SSL连接警告问题的步骤,通过在数据源配置中添加`useSSL=false`来禁用SSL连接。
【已解决】kex_exchange_identification: Connection closed by remote host fatal: Could not read from
【已解决】kex_exchange_identification: Connection closed by remote host fatal: Could not read from
|
7月前
|
Ubuntu Linux C语言
Could not establish connection to “xx.xx.xx.xx“:The VS Code Server faild to start.【重要解决方案】
Could not establish connection to “xx.xx.xx.xx“:The VS Code Server faild to start.【重要解决方案】
253 0
|
网络安全
解决WARN: Establishing SSL connection without server‘s identity verification is not recommended警告问题~
解决WARN: Establishing SSL connection without server‘s identity verification is not recommended警告问题~
201 0
|
存储 关系型数据库 MySQL
警告解决:Establishing SSL connection without server‘s identity verification is not recommended. Accordin
警告解决:Establishing SSL connection without server‘s identity verification is not recommended. Accordin
1934 0
|
Java 关系型数据库 网络安全
Java连接数据库警告WARN: Establishing SSL connection without server's identity ......
今天搭了个框架,发现数据库发出了警告 Fri Mar 23 13:49:33 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended.
3939 0

热门文章

最新文章

下一篇
开通oss服务