如何去检测网络的连接状态
来源:互联网 发布:手机 如何禁止安装软件 编辑:程序博客网 时间:2024/04/29 06:42
1. 方法定义
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ;
2. 方法说明
参数:
connectionDescription : 连接说明
reservedValue : 保留值
返回值:
true: On Line
false: Off Line
3. 调用方法
a. 你必须在你的code里引用System.Runtime.InteropServices,否则,会有编译错误
b. 定义一个变量 int I = 0;
c. 调用bool state = InternetGetConnectedState(out I,0);
using System.Runtime.InteropServices;
namespace internet
...{
public class Class1
...{
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ;
public Class1()...{}
private bool IsConnected()
...{
int I=0;
bool state = InternetGetConnectedState(out I,0);
return state;
}
}
}
namespace internet
...{
public class Class1
...{
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ;
public Class1()...{}
private bool IsConnected()
...{
int I=0;
bool state = InternetGetConnectedState(out I,0);
return state;
}
}
}
- 如何去检测网络的连接状态
- 如何去检测网络的连接状态(C#)
- 如何去检测网络的连接状态(C#)
- 如何去检测网络的连接状态(C#)
- C#如何去检测网络的连接状态
- 检测网络连接状态
- 检测网络连接状态
- C#检测网络的连接状态
- C#检测网络的连接状态
- 网络连接状态检测的一个方法
- Android 检测网络连接状态
- Android 检测网络连接状态
- Android 检测网络连接状态
- IOS检测网络连接状态
- IOS检测网络连接状态
- IOS检测网络连接状态
- IOS检测网络连接状态
- Android 检测网络连接状态
- hello
- ASP 系列函数大全
- FCkeditor笔记
- N多条经典笑话
- ftp命令大全
- 如何去检测网络的连接状态
- .NET Remoting 体系结构评估
- 使用(C++库)ifstream读文件数据
- 异步工作流体系结构的选择
- 海边的拾稻者
- A9财务管理软件与金蝶、用友财务管理软件功能比较表(一)
- 学习
- 6年的感觉
- 看到一篇英文招聘信息有感