Environment.MachineName Eigenschap

Definitie

Hiermee haalt u de NetBIOS-naam van deze lokale computer op.

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

Waarde van eigenschap

De naam van deze computer.

Uitzonderingen

De naam van deze computer kan niet worden verkregen.

Voorbeelden

In het volgende voorbeeld wordt de naam weergegeven van de computer waarop het codevoorbeeld wordt uitgevoerd. (De computernaam wordt om veiligheidsredenen weggelaten uit de voorbeelduitvoer.)

// 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---!
'

Opmerkingen

De naam van deze computer wordt ingesteld bij het opstarten van het systeem wanneer de naam wordt gelezen uit het register. Als deze computer een knooppunt in een cluster is, wordt de naam van het knooppunt geretourneerd.

Van toepassing op