Environment.MachineName Eigenschaft

Definition

Ruft den NetBIOS-Namen dieses lokalen Computers ab.

public:
 static property System::String ^ MachineName { System::String ^ get(); };
public static string MachineName { get; }
static member MachineName : string
Public Shared ReadOnly Property MachineName As String

Eigenschaftswert

Der Name dieses Computers.

Ausnahmen

Der Name dieses Computers kann nicht abgerufen werden.

Beispiele

Im folgenden Beispiel wird der Name des Computers angezeigt, auf dem das Codebeispiel ausgeführt wird. (Der Computername wird aus Sicherheitsgründen aus sicherheitsgründen aus der Beispielausgabe weggelassen.)

// Sample for the Environment.MachineName property
using System;

class Sample
{
    public static void Main()
    {
    Console.WriteLine();
//  <-- Keep this information secure! -->
    Console.WriteLine("MachineName: {0}", Environment.MachineName);
    }
}
/*
This example produces the following results:
(Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked "!---OMITTED---!".)

MachineName: !---OMITTED---!
*/
// Sample for the Environment.MachineName property
open System

//  <-- Keep this information secure! -->
printfn $"\nMachineName: {Environment.MachineName}"

// This example produces the following results:
//     (Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked "!---OMITTED---!".)
//
//     MachineName: !---OMITTED---!
' Sample for the Environment.MachineName property
Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      '  <-- Keep this information secure! -->
      Console.WriteLine("MachineName: {0}", Environment.MachineName)
   End Sub
End Class
'
'This example produces the following results:
'(Any result that is lengthy, specific to the machine on which this sample was tested, 
'or reveals information that should remain secure, has been omitted 
'and marked "!---OMITTED---!".)
'
'MachineName: !---OMITTED---!
'

Hinweise

Der Name dieses Computers wird beim Systemstart eingerichtet, wenn der Name aus der Registrierung gelesen wird. Wenn dieser Computer ein Knoten in einem Cluster ist, wird der Name des Knotens zurückgegeben.

Gilt für: