Environment.MachineName-Eigenschaft
Ruft den NetBIOS-Namen dieses lokalen Computers ab.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Shared ReadOnly Property MachineName As String
'Usage
Dim value As String
value = Environment.MachineName
public static string MachineName { get; }
public:
static property String^ MachineName {
String^ get ();
}
/** @property */
public static String get_MachineName ()
public static function get MachineName () : String
Eigenschaftenwert
Eine Zeichenfolge mit dem Namen dieses Computers.
Ausnahmen
Ausnahmetyp | Bedingung |
---|---|
Der Name dieses Computers kann nicht ermittelt werden. |
Hinweise
Der Name des Computers wird beim Systemstart ermittelt, wenn der Name aus der Registrierung gelesen wird. Wenn der Computer ein Knoten in einem Cluster ist, wird der Name des Knotens zurückgegeben.
Beispiel
Im folgenden Codebeispiel wird der Name des Computers angezeigt, auf dem das Codebeispiel ausgeführt wird. (Der Computername wird in der Ausgabe des Codebeispiels aus Sicherheitsgründen weggelassen.)
' Sample for the Environment.MachineName property
Imports System
Class Sample
Public Shared Sub Main()
Console.WriteLine()
' <-- Keep this information secure! -->
Console.WriteLine("MachineName: {0}", Environment.MachineName)
End Sub 'Main
End Class 'Sample
'
'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
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
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
import System.*;
class Sample
{
public static void main(String[] args)
{
Console.WriteLine();
// <-- Keep this information secure! -->
Console.WriteLine("MachineName: {0}", Environment.get_MachineName());
} //main
} //Sample
/*
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---!
*/
.NET Framework-Sicherheit
- EnvironmentPermission für Vollzugriff auf die COMPUTERNAME-Umgebungsvariable. Zugeordnete Enumeration: EnvironmentPermissionAccess.Read
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0