Internet
Using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Query the computer IP on the network and user needs reference
Using System.Data;
Using System.IO;
Using System.Net;
Using System.Net.Sockets;
Using System.Threading;
Critical reference Space System.directoryservices.dll,system.management.dll
Using System.DirectoryServices;
Using System.Management;
Get all computer IP and current logged-in users in a network Neighborhood
String Strdomain;
String StrComputer;
String strshare;
DirectoryEntry Root =new DirectoryEntry ("WinNT:");
foreach (DirectoryEntry Domain in Root). Children)
{
Enumerate workgroup or domain
Strdomain=domain.name;
COMBOBOX1.ITEMS.ADD (Strdomain);
foreach (DirectoryEntry Computer in Domain.children)
{
Enumerate computers that specify a workgroup or domain
if (Computer.SchemaClassName.Equals ("Computer"))
{
Strcomputer=computer.name;
COMBOBOX2.ITEMS.ADD (StrComputer);
Enumerate shared folders for the specified computer
To get a shared folder on this computer
ManagementObjectSearcher searcher = new ManagementObjectSearcher ("SELECT * from Win32_Share");
foreach (ManagementObject share in searcher. Get ())
{
strshare=share["Name"]. ToString ();
COMBOBOX3.ITEMS.ADD (Strshare);
}
}
}
}