日期:2014-05-17 浏览次数:20851 次
private delegate void Info(string thisgroup,ListBox lb);
Info a =new Info(ComputerInfo);
/// <summary>
/// 获取选中工作组下的所有计算机
/// </summary>
/// <param name="thisgroup">工作组名称</param>
/// <param name="lb">ListBox2</param>
private static void ComputerInfo(string thisgroup,ListBox lb)
{
DirectoryEntry MainGroup = new DirectoryEntry("WinNT:");
foreach (DirectoryEntry domain in MainGroup.Children)
{
if (domain.Name == thisgroup)
{
lb.Items.Clear();
foreach (DirectoryEntry pc in domain.Children)
{
if (pc.Name != "Schema")//Schema是结束标记
lb.Items.Add(pc.Name);
}
}
}
}
private void Form1_Load(object sender, EventArgs e)