zoukankan      html  css  js  c++  java
  • C# 异步获取验证码

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

    using CodeClassLibrary;
    using System.IO;
    using System.Net;

    namespace ValidatorCodeDemo
    {
        public partial class frmValidatorCode : Form
        {
            public frmValidatorCode()
            {
                InitializeComponent();
                this.GetCode();
            }

            private void btnRefresh_Click(object sender, EventArgs e)
            {
                this.GetCode();
            }

            /// <summary>
            /// 产生新的验证码
            /// </summary>
            private void GetCode()
            {
                try
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://checkcode.taobao.com/auction/checkcode?sessionID=eb3f99fbe975258ea87bc24c235ab24f&r=1237173457015");
                    Stream responseStream = ((HttpWebResponse)request.GetResponse()).GetResponseStream();
                    Image original = Image.FromStream(responseStream);
                    Bitmap bitMap = new Bitmap(original);
                    this.pBoxCode.Image = bitMap;           //注意:替换为你的PictureBox控件名字
                    responseStream.Close();

                }
                catch (Exception exception)
                {
                    MessageBox.Show("ERROR:" + exception.Message);
                }
            }

        }
    }

  • 相关阅读:
    Delphi常用内存管理函数
    delphi中VirtualStringTree树使用方法
    Delphi常量
    delphi中的copy函数和pos函数
    delphi 中 delete的用法
    字软元件和位软元件的区别
    Virtual Treeview使用要点
    QTreeWidget搜索功能---遍历QTreeWidget
    C 语言使用 sqlite3
    opendir 与 readdir
  • 原文地址:https://www.cnblogs.com/lifuyun/p/lifuyun09112002.html
Copyright © 2011-2022 走看看