Environment.MachineName Environment.MachineName Environment.MachineName Environment.MachineName Property

Definizione

Ottiene il nome NetBIOS del computer locale.Gets the NetBIOS name of this local computer.

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

Valore della proprietà

Stringa contenente il nome di questo computer.A string containing the name of this computer.

Eccezioni

Non è possibile ottenere il nome del computer.The name of this computer cannot be obtained.

Esempi

Nell'esempio seguente viene visualizzato il nome del computer in cui viene eseguito l'esempio di codice.The following example displays the name of the computer that runs the code example. Il nome del computer viene omesso nell'output di esempio per motivi di sicurezza.(The machine name is omitted from the example output for security reasons.)

// Sample for the Environment::MachineName property
using namespace System;
int 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 S"!---OMITTED---!".)

MachineName: !---OMITTED---!
*/
// 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
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---!
'

Commenti

Il nome di questo computer viene stabilito all'avvio del sistema quando il nome viene letto dal registro di sistema.The name of this computer is established at system startup when the name is read from the registry. Se il computer è un nodo di un cluster, viene restituito il nome del nodo.If this computer is a node in a cluster, the name of the node is returned.

Sicurezza

EnvironmentPermission
per l'accesso in lettura alla variabile di ambiente COMPUTERname.for read access to the COMPUTERNAME environment variable. Enumerazione associata: ReadAssociated enumeration: Read

Si applica a