private void GetIpsbtn_Click(object sender, EventArgs e) { PolycomSettings settings = new PolycomSettings(); IPcalcutor ipcalculator = new IPcalcutor(ref settings); ipcalculator.GetLocalIPAddresses(ref settings); dataGridView1.DataSource = table; }
private void Updatetable(string loopip, string mac, string machine, PolycomSettings Main) { Main.table.Rows.Add(loopip, mac, machine); }
public void GetLocalIPAddresses(ref PolycomSettings PolycomMain) { string value = ""; //Console.WriteLine("Gateways"); NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface adapter in adapters) { IPInterfaceProperties adapterProperties = adapter.GetIPProperties(); GatewayIPAddressInformationCollection addresses = adapterProperties.GatewayAddresses; if (addresses.Count > 0) { //Console.WriteLine(adapter.Description); foreach (GatewayIPAddressInformation address in addresses) { //Console.WriteLine(" Gateway Address ......................... : {0}", // address.Address.ToString()); Show("Gateway Address" + address.Address.ToString()); value = address.Address.ToString(); } //Console.WriteLine(); } if (value != string.Empty) { break; } } int length = value.Length; int c = 0; for (int ex = 0; ex < length; ex++) { if (value[ex] == '.') { c++; } if (c == 3) { PolycomMain.anotherValue = value.Substring(0, ex + 1); break; } } for (int i = 2; i <= 254; i++) { string loopip = PolycomMain.anotherValue + i; WaitCallback func = delegate(object state) { if (PingIP(loopip)) { string mac = GetMacAddress(loopip); string machine = GetMachineNameFromIPAddress(loopip); //ASK USAMA ERROR HERE try { polycomsetting.table.Rows.Add(loopip, mac, machine); } catch (Exception ex) { } } }; ThreadPool.QueueUserWorkItem(func); } //polycom.table = Mytable; }
public IPcalcutor(ref PolycomSettings Mainpage) { this.polycomsetting = Mainpage; }