using System;
using System.Drawing;
//using System.Management;
using System.Net;
using System.Net.Sockets;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
//
//name
//
string hostInfo = Dns.GetHostName();
// string host=
//
//IP
string s=null;
System.Net.IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList;
for (int i = 0; i < addressList.Length; i++)
{
s += addressList[i].ToString();
}
//
//mac
//
//ManagementClass mc;
//mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
//ManagementObjectCollection moc = mc.GetInstances();
//foreach (ManagementObject mo in moc)
//{
// if (mo["IPEnabled"].ToString() == "True")
// mac = mo["MacAddress"].ToString();
//}
string mac=null;
txtName.Text = hostInfo;
txtIp.Text = s;
txtMac.Text = mac;
button1.Enabled = false;
button2.Focus();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
8:56:58