判断是否联网

来源:互联网 发布:淘宝如何开店铺步骤 编辑:程序博客网 时间:2024/06/05 09:14

参考文章: http://hi.baidu.com/brotherzhuo/item/a354444e79129be61e19bcd6


①下载wininet.dll,放到Plugins文件夹。


②写接口

using UnityEngine;using System.Collections;using System.Runtime.InteropServices;public class PCInterface : MonoBehaviour {    //检查并返回是否联网    [DllImport("winInet.dll")]    private static extern bool InternetGetConnectedState(ref int dwFlag, int dwReserved);    public static bool CheckConnect()    {             int dwFlag = new int();        return InternetGetConnectedState(ref dwFlag, 0);    }}


0 0