private void Form11_Load(object sender, EventArgs e)
{
GetVerCode();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != null && textBox1.Text != "")
{
if (textBox1.Text == label1.Text)
{
MessageBox.Show("验证成功!");
}
else
{
MessageBox.Show("验证码错误!");
}
}
else
{
MessageBox.Show("请输入验证码!");
}
}
private void button2_Click(object sender, EventArgs e)
{
GetVerCode();
}
public void GetVerCode()
{
//获取GB2312编码页(表)
Encoding gb = Encoding.GetEncoding("gb2312");
//调用函数产生4个随机中文汉字编码
object[] bytes = CreateRegionCode(4);
//根据汉字编码的字节数组解码