private void GetMachines()//(object sender, EventArgs e) { string MachineDetails; int MachineCheckBox = 0; string MyMachineName = Environment.MachineName; if (System.Net.Dns.GetHostName().Length < 16) { System.Net.Dns.GetHostName().ToString(); } else { System.Net.Dns.GetHostName().Substring(0, 15).ToUpper(); } DirectoryEntry root = new DirectoryEntry("WinNT:"); foreach (DirectoryEntry computers in root.Children) { foreach (DirectoryEntry computer in computers.Children) { string ComputerName = computer.Name; if ((computer.Name != "Schema") && (ComputerName != MyMachineName))// "Composer_A")) { MachineCheckBox = MachineCheckBox + 1; CheckBox box; MachineDetails = computer.Name;// +"\r\n"; box = new CheckBox(); IPAddress[] ipaddress = Dns.GetHostAddresses(ComputerName); foreach (IPAddress ip4 in ipaddress.Where(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)) { box.Tag = ip4; } System.Net.Dns.GetHostAddresses(ComputerName); box.Text = MachineDetails; box.Checked = true; box.AutoSize = true; box.Location = new Point(10, MachineCheckBox * CheckBoxSpacing); //vertical //box.Location = new Point(i * 50, 10); //horizontal //this.Controls.Add(box); grpMachines.Controls.Add(box); } } int groupwidth = grpRemovableDrives.Size.Width; int grpMachinesHeight = grp1stControl + (MachineCheckBox * CheckBoxSpacing); if (grpMachinesHeight < 36) { grpMachinesHeight = 36; } grpMachines.Size = new Size(groupwidth, grpMachinesHeight); this.Size = new Size(this.Size.Width, (grpMachines.Location.Y + grpMachines.Size.Height) + 50); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)