获取机器名

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.

时间: 2024-11-13 08:00:21

获取机器名的相关文章

vbs 脚本 获取机器名/IP/MAC

strComputer = "."strMesseage="" Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") '获取本机计算机名Set colSettings = objWMIService.ExecQuery ("Select *

获取机器名和IP地址

VS2010/MFC/对话框 主要用两个函数:gethostname 和 gethostbyname. int CIPADDRESSDlg::StartUp(void) { WORD wVersionRequested; WSAData wsadata; int err; wVersionRequested = MAKEWORD(2, 0); err = WSAStartup(wVersionRequested, &wsadata); if (err != 0) { return err; }

vc获取本地IP和机器名

#include <winsock2.h> #include <string> #include <boost/filesystem.hpp> #pragma comment(lib,"ws2_32.lib") std::string GetLocalIpAndSave(void) { WSADATA wsaData; char name[155]; std::string strIp; PHOSTENT hostinfo; if ( WSAStar

获取当前网络中的电脑数目及MAC-通过MAC查找IP-通过IP查询机器名

1 Microsoft Windows [版本 6.1.7601] 2 版权所有 (c) 2009 Microsoft Corporation.保留所有权利. 3 4 C:\Users\Administrator>netsh 5 netsh>wlan 6 netsh wlan>show hostednetwork 7 8 承载网络设置 9 ----------------------- 10 模式 : 已启用 11 SSID 名称 :“BCOJBConnect_PCWifi” 12 最多

C++实现获取本机机器名及外网IP代码

#include "stdafx.h" #include <WINSOCK2.H> #include <urlmon.h> #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "urlmon.lib") #define MAX_SIZE 1024 int GetLocalIP(); int GetInternetIP(); int main(int argc, c

[源码]K8 Cscan插件 C#获取内网主机IP/机器名/Banner/网页标题

[源码]K8 Cscan模块 C#扫描内网主机IP/机器名/Banner/网页标题源码 Cscan内置Delphi.VC..NET例子,需要更多功能,请自行添加完善 using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Text.RegularExpressions; namespace CscanDLL { public class scan { pub

c# WMI获取机器硬件信息(硬盘,cpu,内存等)

using System; using System.Collections.Generic; using System.Globalization; using System.Management; using System.IO; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; using System.Runtime.InteropServices; using System.

在C语言中以编程的方式获取函数名

调试常用的 __FILE__, __FUNCTION__, __LINE__ 调试常用的 __FILE__, __FUNCTION__, __LINE__ 没想到 VC6 不支持 __FUNCTION__ 所以我写了如下的奇怪代码 //用来记录当前行和当前函数//也可说是记录 堆栈void log_stack(const char *file, int line, const char * function); //当然还要对 __FUNCTION__ 宏作点修饰,因为这个宏只是在函数里面才起作

通过经纬度获取城市名/地址(不需要三方包)

1:getLocation()方法筛选出最优获取经纬度的方法 2:MapThread线程通过将getLocation()获取的经纬度上传而获取城市名 public class PositionActivity extends BaseActivity implements IInit, IResponseHandler, View.OnClickListener { private TextView mLocationTV, mCategoryTV;//位置.种类 private double