首页 > 开发 > 综合 > 正文

判断计算机当前的网络是否连接

2024-07-21 02:25:45
字体:
来源:转载
供稿:网友

using system.runtime.interopservices;
[dllimport("wininet.dll")]

        private extern static bool internetgetconnectedstate(out int connectiondescription, int reservedvalue);


private static bool isconnected()
        {

            int i = 0;

            bool state = internetgetconnectedstate(out i, 0);

            return state;

        }

        static void main(string[] args)
        {
            console.writeline(isconnected().tostring());
        }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表