新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > .Net开发 > Asp.net教程 > 正文:一个dnslookuo例子。。。

一个dnslookuo例子。。。

新客网 XKER.COM 2003-07-12 来源: 收藏本文
testform.cs
------------------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net;

namespace testagain
{
    /// <summary>
    /// Summary description for testform.
    /// </summary>
    public class testform : System.Windows.Forms.Form
    {
        private System.Windows.Forms.TextBox txt_Domain;
        private System.Windows.Forms.Button btn_Find;
        private System.Windows.Forms.Label lbl_result;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public testform(Form f_MainForm)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            this.MdiParent = f_MainForm;

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            protected override void Dispose( bool disposing )
            {
                if( disposing )
                {
                    if(components != null)
                    {
                        components.Dispose();
                    }
                }
                base.Dispose( disposing );
            }

        #region Windows Form Designer generated code
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.txt_Domain = new System.Windows.Forms.TextBox();
                this.lbl_result = new System.Windows.Forms.Label();
                this.btn_Find = new System.Windows.Forms.Button();
                this.SuspendLayout();
                //
                // txt_Domain
                //
                this.txt_Domain.Location = new System.Drawing.Point(104, 56);
                this.txt_Domain.Name = "txt_Domain";
                this.txt_Domain.Size = new System.Drawing.Size(240, 21);
                this.txt_Domain.TabIndex = 1;
                this.txt_Domain.Text = "www.yahoo.com";
                //
                // lbl_result
                //
                this.lbl_result.Location = new System.Drawing.Point(112, 112);
                this.lbl_result.Name = "lbl_result";
                this.lbl_result.Size = new System.Drawing.Size(336, 40);
                this.lbl_result.TabIndex = 0;
                //
                // btn_Find
                //
                this.btn_Find.Location = new System.Drawing.Point(360, 56);
                this.btn_Find.Name = "btn_Find";
                this.btn_Find.Size = new System.Drawing.Size(72, 24);
                this.btn_Find.TabIndex = 2;
                this.btn_Find.Text = "DNSLookUp";
                this.btn_Find.Click += new System.EventHandler(this.btn_Find_Click);
                //
                // testform
                //
                this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
                this.ClientSize = new System.Drawing.Size(536, 329);
                this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                              this.btn_Find,
                                                                              this.txt_Domain,
                                                                              this.lbl_result});
                this.MaximizeBox = false;
                this.MinimizeBox = false;
                this.Name = "testform";
                this.ShowInTaskbar = false;
                this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                this.Text = "testform";
                this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                this.ResumeLayout(false);

            }
        #endregion

            private void btn_Find_Click(object sender, System.EventArgs e)
            {
                lbl_result.Text = "正在解析中,请稍候...";
                IPHostEntry ip = Dns.GetHostByName(this.txt_Domain.Text);
                IPAddress[] ipaddr = ip.AddressList;

                for (int i=0;i<ipaddr.Length;i++)
                {
                    lbl_result.Text += "\r\n" + ipaddr[i].ToString();
                }
            }
        }
}
 
收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐