/// <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(); //启用网络 } } }
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(); //禁用网络 } } } }
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(); //禁用网络 } } } }