Exemplo n.º 1
0
        /// <summary>
        /// 重新连接
        /// </summary>
        private void ReConnect()
        {
            NetSharingManagerClass netSharingMgr             = new NetSharingManagerClass();
            INetSharingEveryConnectionCollection connections = netSharingMgr.EnumEveryConnection;

            foreach (INetConnection connection in connections)
            {
                INetConnectionProps connProps = netSharingMgr.get_NetConnectionProps(connection);
                if (connProps.MediaType == tagNETCON_MEDIATYPE.NCM_LAN)
                {
                    connection.Disconnect(); //禁用网络
                    connection.Connect();    //启用网络
                }
            }
        }
Exemplo n.º 2
0
        public static void Control(bool isConnect)
        {
            NetSharingManagerClass netSharingMgr             = new NetSharingManagerClass();
            INetSharingEveryConnectionCollection connections = netSharingMgr.EnumEveryConnection;

            foreach (INetConnection connection in connections)
            {
                INetConnectionProps connProps = netSharingMgr.get_NetConnectionProps(connection);
                if (connProps.MediaType == tagNETCON_MEDIATYPE.NCM_LAN)
                {
                    if (isConnect)
                    {
                        connection.Connect(); //启用网络
                    }
                    else
                    {
                        connection.Disconnect(); //禁用网络
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void localnetface(string signer)
        {
            NetSharingManagerClass netSharingMgr             = new NetSharingManagerClass();
            INetSharingEveryConnectionCollection connections = netSharingMgr.EnumEveryConnection;

            foreach (INetConnection connection in connections)
            {
                INetConnectionProps connProps = netSharingMgr.get_NetConnectionProps(connection);
                if (connProps.MediaType == tagNETCON_MEDIATYPE.NCM_LAN)
                {
                    if (signer == "on")
                    {
                        connection.Connect();    //启用网络
                    }
                    else if (signer == "off")
                    {
                        connection.Disconnect(); //禁用网络
                    }
                }
            }
        }