using System;
using System.Runtime.InteropServices;
namespace MyAssist
{
/// <summary>
/// netstat 的摘要说明。
/// </summary>
public class netstat
{
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ;
public bool IsConnected()
{
int I=0;
bool state = InternetGetConnectedState(out I,0);
return state;
}
}
}
本文介绍了一个使用C#实现的简单类netstat,该类通过调用wininet.dll中的InternetGetConnectedState函数来检查计算机是否连接到互联网。通过示例代码展示了如何在.NET应用程序中集成网络连接状态检查功能。
731

被折叠的 条评论
为什么被折叠?



