PDA

View Full Version : سوال: این کد برای پیدا کردن کامپیوترهای موجود روی شبکه هستش .



mmmmmmmmmb
دوشنبه 13 آذر 1391, 22:30 عصر
این کد برای پیدا کردن کامپیوترهای موجود روی شبکه هستش . کسی می توونه یه توضیح کلی از این کد بهم بده ؟:متفکر::افسرده:



public IPHostEntry[] GetNetworkIPAddresses()

{



List<IPHostEntry> IPList = new List<IPHostEntry>();



try

{



ProcessStartInfo PSI = new ProcessStartInfo("CMD.exe", "/C Net View");

PSI.CreateNoWindow =

true;

PSI.RedirectStandardOutput =

true;

PSI.WindowStyle =

ProcessWindowStyle.Hidden;

PSI.UseShellExecute =

false;



string[] CmdRet = Process.Start(PSI).StandardOutput.ReadToEnd().Spli t(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);



if (CmdRet[0] == "There are no entries in the list.")

{

IPList.Add(

Dns.GetHostEntry(IPAddress.Parse("127.0.0.1")));



return IPList.ToArray();

}



else



for (int nCmp = 2; nCmp < (CmdRet.Length - 1); nCmp++)

IPList.Add(

Dns.GetHostEntry(CmdRet[nCmp].Trim('\\', ' ')));



return (IPList.ToArray());

}



catch

{

IPList.Add(

Dns.GetHostEntry(IPAddress.Parse("127.0.0.1")));



return IPList.ToArray();

}

}