WPF中的IP地址 [英] IP address in WPF

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

问题描述

朋友们,
我尝试在WPF中获取本地计算机的ip,但是它失败了...
我已经在WinForm中完成了该操作,但是在WPF中它不起作用.
有人可以给我一些有效的代码吗?
谢谢大家.

Hi friends,
I try to get the ip of the local computer in WPF but it fail...
I allready done that in WinForm but in WPF it does not work.
can someone give me a little code that works?
Thank you all.

推荐答案

您需要发布代码. WPF与IP地址无关,因此,只要导入提供所调用方法的dll,您的代码就可以正常工作.
You need to post your code. WPF has NOTHING to do with IP addresses, therefore your code will work fine, so long as you import the dlls that provide the methods you call.


IPAddress[] a = Dns.GetHostByName(Dns.GetHostName()).AddressList;
 string ip = a[0].ToString();
        txtIp.Text = ip;


这篇关于WPF中的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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