zoukankan      html  css  js  c++  java
  • 【小技巧】C#判断电脑是否联网

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    //添加特殊命名空间
    using System.Runtime.InteropServices;
    
    namespace GPS解析上位机_在线版_
    {
        public partial class Form1 : Form
        {
            [DllImport("wininet")]
            //判断网络状况的方法,返回值true为连接,false为未连接  
            public extern static bool InternetGetConnectedState(out int conState, int reder); 
    
            public Form1()
            {
                InitializeComponent();
    
                int i = 0;
                if((InternetGetConnectedState(out i, 0)==true))
                {
                    MessageBox.Show("设备联网正常!");
                }
                else
                {
                    MessageBox.Show("设备不可联网!");
                }
            }
    
           private void Form1_Load(object sender, EventArgs e)
            {
    
            }
        }
    }
  • 相关阅读:
    第五周总结
    10.24号进度报告
    10.23日进度报告
    10.22日进度报告
    10.21日进度报告
    10.20号进度总结
    10.19日进度总结
    第四周总结
    10.18日进度博客
    2020下第六周总结
  • 原文地址:https://www.cnblogs.com/achao123456/p/5916825.html
Copyright © 2011-2022 走看看