http://www.cnblogs.com/atree/archive/2011/04/01/CSharp-Internet-wininet-dll.html

 

//判断计算机是否能够连接到Internet的API
//wininet.dll是Windows应用程序网络相关模块。该文件隶属于%\WINDOWS\SYSTEM32目录下动态库连接文件。该文件不可缺失,属于关键链接库。当文件丢失或者损坏时,届时将无法完成Explorer进程(即桌面以及基于该进程的IE浏览器等,可使用不基于IE浏览器进行访问网络)

[DllImport(
"wininet.dll")]
publicexternstaticbool InternetGetConnectedState( outint Description, int ReservedValue ) ;

//创建一个调用API函数(封装为C#方式).
///<summary>
/// 查看网络是否连接到公网
///</summary>
///<returns>返回Ture:可以连接到Internet,False则连接不上</returns>
publicstaticbool IsConnectedToInternet( )
{
int Desc ;
return InternetGetConnectedState(out Desc, 0);
}

懒得复制代码,狠狠点击这里,快速下载源文件:https://files.cnblogs.com/atree/WininetAPI.rar

相关文章:

  • 2021-10-21
  • 2022-12-23
  • 2022-02-17
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
猜你喜欢
  • 2021-05-29
  • 2021-12-16
  • 2022-12-23
相关资源
相似解决方案