OperationalStatus 枚举

定义

指定网络接口的操作状态。

public enum class OperationalStatus
public enum OperationalStatus
type OperationalStatus = 
Public Enum OperationalStatus
继承
OperationalStatus

字段

Dormant 5

网络接口不处于传输数据包的状态;它正等待外部事件。

Down 2

网络接口无法传输数据包。

LowerLayerDown 7

网络接口无法传输数据包,因为它运行在一个或多个其他接口之上,而这些“低层”接口中至少有一个已关闭。

NotPresent 6

由于缺少组件(通常为硬件组件),网络接口无法传输数据包。

Testing 3

网络接口正在运行测试。

Unknown 4

网络接口的状态未知。

Up 1

网络接口已运行,可以传输数据包。

示例

下面的代码示例显示本地计算机上所有接口的摘要。

void ShowInterfaceSummary()
{
   array<NetworkInterface^>^interfaces = NetworkInterface::GetAllNetworkInterfaces();
   System::Collections::IEnumerator^ myEnum5 = interfaces->GetEnumerator();
   while ( myEnum5->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum5->Current);
      Console::WriteLine( "Name: {0}", adapter->Name );
      Console::WriteLine( adapter->Description );
      Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) );
      Console::WriteLine( "  Interface type .......................... : {0}",
         adapter->NetworkInterfaceType );
      Console::WriteLine( "  Operational status ...................... : {0}", adapter->OperationalStatus );
      String^ versions = "";

      // Create a display string for the supported IP versions.
      if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) )
      {
         versions = "IPv4";
      }

      if ( adapter->Supports( NetworkInterfaceComponent::IPv6 ) )
      {
         if ( versions->Length > 0 )
         {
            versions = String::Concat( versions, " " );
         }

         versions = String::Concat( versions, "IPv6" );
      }

      Console::WriteLine( "  IP version .............................. : {0}", versions );
      Console::WriteLine();
   }

   Console::WriteLine();
}
public static void ShowInterfaceSummary()
{

    NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in interfaces)
    {
        Console.WriteLine ("Name: {0}", adapter.Name);
        Console.WriteLine(adapter.Description);
        Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length,'='));
        Console.WriteLine("  Interface type .......................... : {0}", adapter.NetworkInterfaceType);
        Console.WriteLine("  Operational status ...................... : {0}",
            adapter.OperationalStatus);
        string versions ="";

        // Create a display string for the supported IP versions.
        if (adapter.Supports(NetworkInterfaceComponent.IPv4))
        {
             versions = "IPv4";
         }
        if (adapter.Supports(NetworkInterfaceComponent.IPv6))
        {
            if (versions.Length > 0)
            {
                versions += " ";
             }
            versions += "IPv6";
        }
        Console.WriteLine("  IP version .............................. : {0}", versions);
        Console.WriteLine();
    }
    Console.WriteLine();
}

注解

此枚举定义 属性的有效值 OperationalStatus

适用于