【小工具】Winform查询IP|Md5加密|打开IE|复制|对话框

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

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
           //查询输入的域名
            string net = this.textBox_net.Text.ToString();
            if (net.Trim() == string.Empty || net == "")
            {
                this.textBox_IP.Text = "请输入域名";
                return;
            }
            try
            {
                System.Net.IPHostEntry host = System.Net.Dns.GetHostEntry(net);
                this.textBox_IP.Text = host.AddressList.GetValue(0).ToString();
            }
            catch (Exception ex)
            {
                this.textBox_IP.Text = "查询有误";
                return;
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            //MD5
            string word = this.textBox_word.Text.ToString();
            if (word.Trim() == string.Empty || word.Trim() == "")
            {
                this.textBox_mi.Text = "请输入需要加密的字符";
                return;
            }
            try
            {
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] encryptedBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(word));
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < encryptedBytes.Length; i++)
                {
                    sb.AppendFormat("{0:x2}", encryptedBytes[i]);
                }
                this.textBox_mi.Text =  sb.ToString().ToUpper();
            }
            catch(Exception ex1)
            {
                this.textBox_mi.Text = "加密有误";
                return;
            }
        }

        private void OpenIE(string neturl)
        {
            //打开浏览器
            System.Diagnostics.Process.Start(neturl);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            string neturl = "http://www.baidu.com";
            this.OpenIE(neturl);
        }

        private void button10_Click(object sender, EventArgs e)
        {
            string neturl = "http://www.aoyoo.com";
            this.OpenIE(neturl);
        }

        private void button11_Click(object sender, EventArgs e)
        {
            string neturl = "http://www.7v7.com.cn";
            this.OpenIE(neturl);
        }

        private void button9_Click(object sender, EventArgs e)
        {
            //临时会话
            string qq = this.textBox_qq.Text.ToString();
            string neturl = "tencent://message/?uin="+qq;
            this.OpenIE(neturl);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //复制文本框内容
            if (this.textBox_IP.Text.ToString() != "")
            {
                Clipboard.SetDataObject(textBox_IP.Text.ToString());
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (this.textBox_mi.Text.ToString() != "")
            {
                Clipboard.SetDataObject(textBox_mi.Text.ToString());
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            Clipboard.SetDataObject("121.10.112.73");
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Clipboard.SetDataObject("121.10.112.230");
        }

        private void button6_Click(object sender, EventArgs e)
        {
            Clipboard.SetDataObject("121.10.107.63");
        }

        private void textBox_net_KeyPress(object sender, KeyPressEventArgs e)
        {
            //文本框的键盘监听事件
            if (e.KeyChar == 13)
            {
                this.button1_Click(sender,e);
            }
        }

        private void textBox_word_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                this.button3_Click(sender, e);
            }
        }

        private void textBox_qq_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                this.button9_Click(sender, e);
            }
        }
    }
}

 

 

===========补充个

DialogResult result = MessageBox.Show("时间设定为"+ time +",确定删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{

}
else
{

}

 

====================

 

            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.ShowDialog();
            this.textBox_acc.Text = fileDialog.FileName.ToString();

 

友情链接:

 遨游官方论坛 http://www.7v7.cn/?fromuid=177

原文地址:https://www.cnblogs.com/binlunia/p/11267778.html