public void Initial()
{
try
{
if (IsNetworkConnected)
{
SvMaster.Log.WriteInfo("网络连接成功");
}
else
{
SvMaster.Log.WriteError("网络连接失败,请检查网络!");
}
}
catch (Exception ex)
{
SvMaster.Log.WriteError(ex);
}
}
[DllImport("wininet.dll", EntryPoint = "InternetGetConnectedState")]
public extern static bool InternetGetConnectedState(out int conState, int reader);
public static bool IsNetworkConnected
{
get
{
return InternetGetConnectedState(out int n, 0);
}
}
因篇幅问题不能全部显示,请点此查看更多更全内容