首页 > 代码库 > C# 遍历本地网络

C# 遍历本地网络

public static bool IsHNetCfgWayConnected(string opName)       {           NetSharingManagerClass netSharingMgr = new NetSharingManagerClass(); INetSharingEveryConnectionCollection connections = netSharingMgr.EnumEveryConnection;           List<object> conns = new List<object>();           foreach (INetConnection connection in connections)           {               INetConnectionProps connProps = netSharingMgr.get_NetConnectionProps(connection);               if (connProps.MediaType == tagNETCON_MEDIATYPE.NCM_LAN)               {                   if (connProps.Name.Equals(opName))                   {                       return connProps.Status == tagNETCON_STATUS.NCS_CONNECTED;                   }               }           }           return false;       }

 

C# 遍历本地网络