>System.String sQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'"; >System.String sMsgBoxText= ""; > > >System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher(sQuery); >foreach (System.Management.ManagementObject nic in searcher.Get()) >{ > sMsgBoxText= ""; > sMsgBoxText = sMsgBoxText + "Caption = " + nic["Caption"] + "\r\n"; > sMsgBoxText = sMsgBoxText + "Hostname = " + nic["DNSHostName"] + "\r\n"; > sMsgBoxText = sMsgBoxText + "Description = " + nic["Description"] + "\r\n"; > sMsgBoxText = sMsgBoxText + "MACAddress = " + nic["MACAddress"] + "\r\n"; > sMsgBoxText = sMsgBoxText + "ServiceName = " + nic["ServiceName"] + "\r\n"; > > if (nic["DefaultIPGateway"] != null) > { > sMsgBoxText = sMsgBoxText + "DefaultIPGateway = \r\n"; > foreach (System.String sDefaultIPGateway in (System.String[]) nic["DefaultIPGateway"]) > { > sMsgBoxText = sMsgBoxText + " "+sDefaultIPGateway.ToString() + "\r\n"; > } > } > else > { > sMsgBoxText = sMsgBoxText + "DefaultIPGateway = Returned NULL\r\n"; > } > > sMsgBoxText = sMsgBoxText + "IPSubnet = \r\n"; > foreach (System.String sIPSubnet in (System.String[]) nic["IPSubnet"]) > { > sMsgBoxText = sMsgBoxText + " "+sIPSubnet.ToString() + "\r\n"; > } > > > sMsgBoxText = sMsgBoxText + "IPAddress = \r\n"; > foreach (System.String sIPAddress in (System.String[]) nic["IPAddress"]) > { > sMsgBoxText = sMsgBoxText + " "+sIPAddress.ToString() + "\r\n"; > } > > > > MessageBox.Show(sMsgBoxText,"Method #1"); >} >>