C# 断网

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(); //启用网络 } } 需要项目引用COM NetCon,而且在win7/vista下需要管理员权限运行
posted @   adodo1  Views(190)  Comments(0Edit  收藏  举报
点击右上角即可分享
微信分享提示