获取机器名

Posted 楊柳

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取机器名相关的知识,希望对你有一定的参考价值。

Environment.MachineName;
System.Net.Dns.GetHostName();
System.Windows.Forms.SystemInformation.ComputerName;
System.Environment.GetEnvironmentVariable("COMPUTERNAME");

Environment.MachineName
The name of this computer is established at system startup when the name is read from the registry. If this computer is a node in a cluster, the name of the node is returned.

Environment.MachineName and System.Windows.Forms.SystemInformation.ComputerName are identical and returns the computer‘s NetBios name. This name is restricted to 15 characters and only visible on the LAN.

System.Net.Dns.GetHostName() returns the computer‘s TCP/IP based hostname. By adding a domain suffix to the hostname you can resolve your computer‘s IP address across LANs / on the internet.

System.Environment.GetEnvironmentVariable("COMPUTERNAME") returns the computer name set during installation. NetBIOS and hostname are initially set to the same name.

以上是关于获取机器名的主要内容,如果未能解决你的问题,请参考以下文章

获取机器名

java获取本机器的IP(linux和windows)

浏览器端获取局域网IP地址,本机的MAC,以及机器名

oracle如何获取调用者的IP,机器名等信息,以及他们操作的SQL

如何在 C# 中获取本地机器名称?

.NET获取机器信息