You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 regels
938 B

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. namespace HKCardOut.Helper
  9. {
  10. public class HKHelper: Singleton<HKHelper>
  11. {
  12. /// <summary>
  13. /// 判断网络状况的方法,返回值true为连接,false为未连接
  14. /// </summary>
  15. /// <param name="conState"></param>
  16. /// <param name="reder"></param>
  17. /// <returns></returns>
  18. [DllImport("wininet")]
  19. public extern static bool InternetGetConnectedState(out int conState, int reder);
  20. /// <summary>
  21. /// 获取当前网络连接状态
  22. /// </summary>
  23. /// <returns>成功连接网络返回 true,未连接返回 false</returns>
  24. public bool GetNetworkState()
  25. {
  26. return InternetGetConnectedState(out int i, 0);
  27. }
  28. }
  29. }