Using system;
Using system. drawing;
Using system. collections;
Using system. componentmodel;
Using system. Windows. forms;
Using system. Data;
Using system. diagnostics;
Using system. directoryservices;
Using system. serviceprocess;
// The project references system. Management. dll.
Using system. Management;
Using system. net;
Using system. net. Sockets;
Private void mainform_load (Object sender, system. eventargs E)
{
String S = "", MAC = "";
// Obtain the Host Name
String hostinfo = DNS. gethostname ();
// Obtain the Host IP Address
System. net. IPaddress [] Addresslist = DNS. gethostbyname (DNS. gethostname (). Addresslist;
For (INT I = 0; I <Addresslist. length; I ++)
{
S + = Addresslist [I]. tostring ();
}
// Obtain the host Nic 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 ();
}
Textbox1.text = hostinfo;
Textbox2.text = s;
Textbox3.text = MAC;
}