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;
}
上一篇:jQuery Mobile基础


下一篇:JavaScript 基础(四) 循环