会员
周边
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
冷风.NET
---默默無聞
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
获得网上邻居里计算机和他们的ip地址
Posted on
2004-11-22 12:01
冷风.net
阅读(
770
) 评论(
0
)
收藏
举报
using
System;
using
System.Net;
using
System.DirectoryServices;
public
void
ShowComputers()
{
DirectoryEntry root
=
new
DirectoryEntry(
"
WinNT:
"
);
DirectoryEntries domains
=
root.Children;
domains.SchemaFilter.Add(
"
domain
"
);
foreach
(DirectoryEntry domain
in
domains)
{
string
str
=
""
;
str
=
domain.Name;
listBox1.Items.Add(
"
域名:
"
+
str);
DirectoryEntries computers
=
domain.Children;
computers.SchemaFilter.Add(
"
computer
"
);
foreach
(DirectoryEntry computer
in
computers)
{
str
=
""
;
str
+=
"
"
+
computer.Name;
try
{
IPHostEntry ips
=
Dns.GetHostByName(computer.Name);
foreach
(IPAddress ip
in
ips.AddressList)
{
str
+=
"
"
+
ip;
}
}
catch
{
Console.WriteLine(computer.Name);
}
DirectoryEntries users
=
computer.Children;
listBox1.Items.Add(str);
}
}
}
刷新页面
返回顶部
博客园
© 2004-2026
浙公网安备 33010602011771号
浙ICP备2021040463号-3