---
title: "delphi图片验证码"
author: "mathsfan"
date: "2009-02-02T20:43:03Z"
tags: []
slug: "delphi"
draft: false
lastmod: "2009-02-02T20:54:52Z"
id: 322071
url: "https://msdn.iteye.com/blog/322071"
---

验证图片效果如下：
![](http://msdn.iteye.com/upload/picture/pic/30401/b8a11b41-a107-3131-9003-dc72b90c2480.jpg)
调用方法（控件请使用TImage）：
uses imgCheckPS;

//imgPic: TImage;不加LowerCase直接和ImgStr比较则验证时要区分大小写。

>     if not (LowerCase(trim(edtPic.Text))=LowerCase(ImgStr)) then CheckPass(imgPic);
> 

其中ImgStr为图片中的字母数字组成的字符串（imgCheckPS中的全局变量），另外不要忘记在.dpr文件中初始化随机数种子（Randomize;），希望大家喜欢 :)