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.

33 lines
951 B

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