欢迎光临
我们一直在努力

一个dnslookuo例子。。。-.NET教程,Asp.Net开发

建站超值云服务器,限时71元/月

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();
                }
            }
        }
}
 

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 一个dnslookuo例子。。。-.NET教程,Asp.Net开发
分享到: 更多 (0)