|
12345678910111213141516171819202122232425262728293031 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
-
- namespace HKHelper
- {
- public class HKHelper : Singleton<HKHelper>
- {
- /// <summary>
- /// 判断网络状况的方法,返回值true为连接,false为未连接
- /// </summary>
- /// <param name="conState"></param>
- /// <param name="reder"></param>
- /// <returns></returns>
- [DllImport("wininet")]
- public extern static bool InternetGetConnectedState(out int conState, int reder);
- /// <summary>
- /// 获取当前网络连接状态
- /// </summary>
- /// <returns>成功连接网络返回 true,未连接返回 false</returns>
- public bool GetNetworkState()
- {
- return InternetGetConnectedState(out int i, 0);
- }
-
- }
- }
|