1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Windows.Forms;9 usingSystem.Management;Ten namespaceWinnic One { A Public Partial classWinnic:form - { -ManagementClass MC =NewManagementClass ("Win32_NetworkAdapterConfiguration"); the Publicwinnic () - { - InitializeComponent (); -Managementobjectcollection MOC =MC. GetInstances (); + foreach(ManagementObject MOinchMOC) - { + if( (BOOL) mo["ipenabled"] ==true ) A { atTextbox_mac. Text = MO. properties["MACAddress" ]. Value.tostring (); - } - Try - { -Textbox_ip. Text = (mo["IPAddress"] as string[] ). GetValue (0 ). ToString (); -Textbox_subnet.text = (mo["ipsubnet"] as string[] ). GetValue (0 ). ToString (); inTextbox_netgate.text = (mo["DefaultIPGateway"] as string[] ). GetValue (0 ). ToString (); - } to Catch(SystemException/*e*/) + { - //MessageBox.Show (e.tostring (), "Error", messageboxbuttons.ok,messageboxicon.error); the } * } $ This. Text + ="(Make: Lin Hongquan 2009/04/07)";Panax Notoginseng } - } the } +
Read online Mac