码迷,mamicode.com
首页 > 其他好文 > 详细

获取机器名

时间:2016-06-29 13:14:22      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:

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.

获取机器名

标签:

原文地址:http://www.cnblogs.com/dennysong/p/5626275.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!