using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
//查詢網絡上的計算機IP和用戶需要引用
using System.Data;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
//關鍵引用空間System.directoryservices.dll,System.Management.dll
using System.DirectoryServices;
using System.Management;
//獲取網絡鄰居中的所有計算機IP和當前登錄用戶
string strDomain;
string strComputer;
string strShare;
DirectoryEntry root =new DirectoryEntry("WinNT:");
foreach(DirectoryEntry Domain in root.Children)
{
//枚舉工作組或域
strDomain=Domain.Name;
comboBox1.Items.Add(strDomain);
foreach(DirectoryEntry Computer in Domain.Children)
{
//枚舉指定工作組或域的計算機
if(Computer.ScheMaclassName.Equals("Computer"))
{
strComputer=Computer.Name;
comboBox2.Items.Add(strComputer);
//枚舉指定計算機的共享文件夾
//獲取本機共享的文件夾
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from win32_share");
foreach (ManagementObject share in searcher.Get())
{
strShare=share["Name"].ToString();
comboBox3.Items.Add(strShare);
}
}
}
}