確定是否存在網絡連接的最佳方法是什么?
3 回答

忽然笑
TA貢獻1806條經驗 獲得超5個贊
調用此方法以檢查網絡連接。
public static bool IsConnectedToInternet()
{
bool returnValue = false;
try
{
int Desc;
returnValue = Utility.InternetGetConnectedState(out Desc, 0);
}
catch
{
returnValue = false;
}
return returnValue;
}
將其放在代碼行下面。
[DllImport("wininet.dll")]
public extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
- 3 回答
- 0 關注
- 540 瀏覽
添加回答
舉報
0/150
提交
取消