using system;
using system.drawing;
using system.collections;
using system.componentmodel;
using system.windows.forms;
//查詢網(wǎng)絡上的計算機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;
//獲取網(wǎng)絡鄰居中的所有計算機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);
}
}
}
}
新聞熱點
疑難解答