using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;


namespace IPAddressDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            #if DEBUG
                MinimizeBox = false;
            #else       
                MinimizeBox = true;
            #endif
        }

        private void butGetIPAddress_Click(object sender, EventArgs e)
        {
            try
            {
                IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
                IPAddress[] addressList = host.AddressList;

                if (addressList.Length > 0)
                {
                    StringBuilder address = new StringBuilder();
                    foreach (IPAddress a in addressList)
                    {
                        address.Append(a.ToString());
                        address.Append(" ");
                    }
                    label1.Text = address.ToString();
                }

                else
                    MessageBox.Show("Не могу определить IP-адрес", "Ошибка");
            }

            catch (Exception)
            {
                MessageBox.Show("Не могу определить IP-адрес", "Ошибка");
            }
        }

        

        
        
        
        
        
        

        
        
        
        
        
        
        
        
        
        

        
        
        

        
        
        
        


        
    }
}