这里网上重复最多的,这里不是检测网络连接,而是网路。也就是你的物理设备连接了。你的网线连接到了交换机网关了。在计算机系统中的网络连接里面,你的本地连接显示已经连接上了。都是显示网路通了。用此方法。

[DllImport("wininet.dll", EntryPoint = "InternetGetConnectedState")]
        public extern static bool InternetGetConnectedState(out int conState, int reder);
        //参数说明 constate 连接说明 ,reder保留值
        private void button2_Click(object sender, EventArgs e)
        {
            int Desc = 0;
            if (InternetGetConnectedState(out  Desc, 0))
               label1.Text="已连接在网上!";
            else
                label1.Text="未连接在网上!!";
        }  

这里的连接了是指网路不是网络。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2022-02-11
  • 2021-06-08
  • 2022-02-03
猜你喜欢
  • 2021-05-25
  • 2021-10-15
  • 2022-02-01
  • 2021-11-05
  • 2021-09-17
  • 2022-12-23
相关资源
相似解决方案