using System.Management; string stringMAC = “”; string stringIP = “”; ManagementClass MC = new ManagementClass “Win32_NetworkAdapterConfiguration”); ManagementObjectCollection MOC= MC.GetInstances(); foreach(ManagementObject MO in MOC) { if ((bool)MO[“IPEnabled”] == true) { stringMAC += MO[“MACAddress”].ToString(); TextMAC.Text = stringMAC.ToString(); string[] IPAddresses = (string[]) MO[“IPAddress”]; if(IPAddresses.Length > 0) stringIP = IPAddresses[0]; TextIP.Text = stringIP.ToString(); } } 获得客户端ip地址请参考:http://happysnail.org/index.php/archives/367