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);
}
}
}
}
新闻热点
疑难解答