如何使用Vb.Net代码了解哪些计算机与LAN连接(名称和IP地址)? 谢谢 Furqan
答案 0 :(得分:2)
据我所知,这是不可能的,我知道你可以检索有关主机而不是局域网的数据。如果它是Windows Server中的DHCP服务器或XP中的ICS,则可能是可能的。 提供的最佳解决方案是ping本地子网中的所有主机。像ping 192.168.0-255.0-255之类的东西。
答案 1 :(得分:0)
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
TcpClient tcpclnt;
private void Form1_Load(object sender, EventArgs e)
{
String hostname = Dns.GetHostName();
MessageBox.Show(hostname);
IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
//IPHostEntry myipaddlist = Dns.GetHostByName(hostname);
foreach(IPAddress ips in myipaddlist.AddressList)
{
MessageBox.Show(ipa.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
tcpclnt = new TcpClient();
MessageBox.Show("connecting");
tcpclnt.Connect("ur ipadress", 8001);
label1.Text = "connected";
}
catch (Exception ex)
{
MessageBox.Show("error" + ex.StackTrace);
}
}