吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 6488|回复: 11
收起左侧

[其他转载] C#显本机IP信息和服务器信息

 关闭 [复制链接]
sijin 发表于 2008-11-24 22:16
namespace IPExample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            string name = Dns.GetHostName();
            listBox1.Items.Add("本机主机名:" + name);
            IPHostEntry me = Dns.GetHostEntry(name);
            listBox1.Items.Add("本机所有IP地址:");
            foreach (IPAddress ip in me.AddressList)
            {
                listBox1.Items.Add(ip);
            }
            IPAddress localip = IPAddress.Parse("127.0.0.1");
            IPEndPoint iep = new IPEndPoint(localip, 80);
            listBox1.Items.Add("The IPEndPoint is: " + iep.ToString());
            listBox1.Items.Add("The Address is: " + iep.Address);
            listBox1.Items.Add("The AddressFamily is: " + iep.AddressFamily);
            listBox1.Items.Add("The max port number is: " + IPEndPoint.MaxPort);
            listBox1.Items.Add("The min port number is: " + IPEndPoint.MinPort);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            IPHostEntry remoteHost = Dns.GetHostEntry("www.cctv.com");
            IPAddress[] remoteIP = remoteHost.AddressList;
            listBox1.Items.Add("中央电视台:");
            foreach (IPAddress ip in remoteIP)
            {
                IPEndPoint iep = new IPEndPoint(ip, 80);
                listBox1.Items.Add(iep);
            }

        }
    }
}

下载

[ 本帖最后由 sijin 于 2008-11-24 22:19 编辑 ]

IPExample.rar

30.74 KB, 下载次数: 43, 下载积分: 吾爱币 -1 CB

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

liubudan 发表于 2008-11-24 22:23
沙发 ...终于抢到了..支持楼主
lvvv 发表于 2008-11-25 13:38
西氏 发表于 2008-11-28 22:59
wqejnyt 发表于 2008-12-27 04:05
显然不懂C#可是还是要顶你一下。
不过我觉得显本机IP信息和服务器信息还是用E语言来得容易。只不过两个命令就解决。
多情 发表于 2008-12-28 16:47
支持下,看看支持下,看看
雨后的芬芳 发表于 2008-12-28 16:55
有些看不懂。
zhaoxili 发表于 2009-6-6 01:52
刚开始学
hyhappy 发表于 2009-6-10 14:25
初学者,很想要,谢谢了。
tianjun1969 发表于 2009-6-14 09:48
支持下,看看支持下偶下载了试试去
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-16 05:15

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表