helimin19
using System;
using System.Net;
using System.DirectoryServices;

public void ShowComputers()
        
{
            DirectoryEntry root 
= new DirectoryEntry("WinNT:");
            DirectoryEntries domains 
= root.Children;
            domains.SchemaFilter.Add(
"domain");
            
foreach(DirectoryEntry domain in domains)
            
{
                
string str = "";
                str 
= domain.Name;
                listBox1.Items.Add(
"域名:" + str);
                DirectoryEntries computers 
= domain.Children;
                computers.SchemaFilter.Add(
"computer");
                
foreach(DirectoryEntry computer in computers)
                
{
                    str 
= "";
                    str 
+= " " + computer.Name;
                    
try
                    
{
                        IPHostEntry  ips 
= Dns.GetHostByName(computer.Name);
                        
foreach(IPAddress ip in ips.AddressList)
                        
{
                            str 
+= "  " + ip;
                        }

                    }

                    
catch{
                        Console.WriteLine(computer.Name);
                    }

                    DirectoryEntries  users 
= computer.Children;
                    listBox1.Items.Add(str);
                }

            }

        }

分类:

技术点:

相关文章:

  • 2021-06-11
  • 2021-11-05
  • 2022-12-23
  • 2021-06-19
  • 2021-12-26
  • 2021-12-15
  • 2021-09-25
猜你喜欢
  • 2022-12-23
  • 2021-06-13
  • 2022-01-29
  • 2021-09-21
  • 2022-01-03
  • 2021-11-05
  • 2021-12-08
相关资源
相似解决方案