110,500
社区成员
发帖
与我相关
我的任务
分享
Process p = new Process();
p.StartInfo.FileName = "net";
p.StartInfo.Arguments = "view";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
while (!p.StandardOutput.EndOfStream)
{
string s = p.StandardOutput.ReadLine();
if (s.StartsWith(@"\\"))
{
try
{
Console.WriteLine(Dns.GetHostByName(s.Substring(2, s.IndexOf(' ') - 1)).AddressList[0].ToString());
}
catch { }
}
}
IPAddress[] ipadd;
string hostname = Dns.GetHostName();
ipadd=Dns.GetHostAddresses(hostname);
foreach (IPAddress ip in ipadd)
{
MessageBox.Show(hostname);
MessageBox.Show(ip.ToString());
}