从其他PC问题中查找自己的IP地址 [英] Finding Own IP address From other PC question

查看:61
本文介绍了从其他PC问题中查找自己的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好...大家好...我只是想问一下我的代码在使用其他联网PC查找自己的ipaddress时是否存在问题...

hello... Good day to all you... i just want to ask if is there something wrong with my codes in finding my own ipaddress using other networked PC...

dim strhostname as string 
dim strIPaddress as string
strhostname = "mycomputer's_hostname"
strhostname = system.net.dns.gethostname()
stripaddress = system.net.dns.gethostname(strhostname).addresslist(0).tostring()
textbox1.text = stripaddress


我已经有像system.net这样的导入文件了.这里有人可以帮助我吗?我尝试了这段代码,但是没有用……还有没有比这更短的方法了?在此先感谢..


i already had my import like system.net. Anybody here could help me? i tried this code but it didn''t work... is there any shorter way than this? thanks in advance..

推荐答案

请看以下链接:

如何获取机器的IP地址 [ ^ ],也请看一下评论,获得IP的更好方法是:

System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0] .GetIPProperties().UnicastAddresses [0] .Address

另外,本地IP [
Take a look at the following link:

How To Get IP Address Of A Machine[^] also, take a look at the comments, better way to get the IP is:

System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].GetIPProperties().UnicastAddresses[0].Address

Also, Local IP[^]


这篇关于从其他PC问题中查找自己的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆