//此类用于获取当前主机的相关信息 //用法示例 public string example() { string Info = ""; MachineInfo info = MachineInfo.I(); //获取主机的对象信息 Info = "\r\n主机名:" + Dns.GetHostName(); //获取主机名称 Info += "\r\n系统类型:" + info.GetSystemType(); Info += "\r\n物理内存:" + long.Parse(info.GetPhysicalMemory()) / 1024 / 1024 / 1000 + " GB"; Info += "\r\n\r\n本地IP:"; string[] LocalIp = info.GetLocalIpAddress(); foreach (string ip in LocalIp) { Info += "\r\n" + ip; } Info += "\r\n\r\n外网IP:"; string ExternalIp = info.GetExtenalIpAddress(); Info += "\r\n" + ExternalIp; Info += "\r\n\r\nMAC:"; Info += "\r\n" + info.GetNetCardMACAddress(); //Info += "\r\n" + info.GetMacAddress(LocalIp[0]); Info += "\r\n"; Info += "\r\nCPU序列号:" + info.GetCPUSerialNumber(); //Info += "\r\nCPU编号:" + info.GetCPUID(); //Info += "\r\nCPU版本信息:" + info.GetCPUVersion(); Info += "\r\nCPU名称信息:" + info.GetCPUName(); //Info += "\r\nCPU制造厂商:" + info.GetCPUManufacturer(); //Info += "\r\n主板制造厂商:" + info.GetBoardManufacturer(); //Info += "\r\n主板序列号:" + info.GetBIOSSerialNumber(); //Info += "\r\n硬盘序列号:" + info.GetHardDiskSerialNumber(); // Info += "\r\n显卡PNPDeviceID:\r\n" + info.GetVideoPNPID(); //Info += "\r\n声卡PNPDeviceID:\r\n" + info.GetSoundPNPID(); return(Info); }
private void button1_Click(object sender, EventArgs e) { MachineInfo machineInfo = new MachineInfo(); textBox1.Text = machineInfo.example(); }