zoukankan      html  css  js  c++  java
  • 【小工具】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

  • 相关阅读:
    黄聪:C#多线程教程(1):BeginInvoke和EndInvoke方法,解决主线程延时Thread.sleep柱塞问题(转)
    黄聪:C#类似Jquery的html解析类HtmlAgilityPack基础类介绍及运用
    黄聪:国内com域名转移到Godaddy详细教程(转)
    黄聪:Navicat for MySQL的1577错误解决
    黄聪:VPS配置Filezilla Server支持FTP的Passive被动模式(FTP连接不上怎么办?有详细教程)
    黄聪:Microsoft office 2013版下载、安装及破解工具下载破解教程(Windows Toolkit)
    黄聪:mysql搬家,直接复制data文件夹(*.MYD,*.MYI,innodb)出错,无法正常显示
    黄聪:WordPress默认编辑器可视化切换不见了,非插件导致消失问题
    黄聪:自定义WordPress顶部管理工具条的技巧(转)
    黄聪:VS2010中“新建项目”却没有“解决方案”节点,如何调出来
  • 原文地址:https://www.cnblogs.com/binlunia/p/11267778.html
Copyright © 2011-2022 走看看