打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
delphi7调用爱莉文验证码识别库

delphi7调用爱莉文验证码识别库

  

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TypeInitKeyCode=function(idx:Integer):Integer;cdecl;
  TypeFreeKeyCode=function(idx:Integer):Integer;cdecl;
  TypeGetCodeResult=function(filename:string;outReg:Pointer;idx:Integer):Integer;cdecl;
  TypeGetCodeFromURL=function(urstr:string;refurl:string;cookie:string;retcode:Pointer;bsave:Integer;idx:Integer):Integer;cdecl;


  TForm1 = class(TForm)
    lblInputfile: TLabel;
    edtInputfile: TEdit;
    lbl1: TLabel;
    edtReg: TEdit;
    btnTest: TButton;
    CheckBox1: TCheckBox;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure btnTestClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  nKeyCodeIndex:Integer;
  hMod:Thandle;
  InitKeyCode:TypeInitKeyCode;
  FreeKeyCode:TypeFreeKeyCode;
  GetCodeResult:TypeGetCodeResult;
  GetCodeFromURL:TypeGetCodeFromURL;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  nKeyCodeIndex:=-1;
  hMod:=LoadLibrary('ZHKeyCode.dll');
  if(hMod<>0) then
    begin
        @InitKeyCode := GetProcAddress(hMod,'www_zfuwen_com_QQ_251578917_InitKeyCode');
        @FreeKeyCode := GetProcAddress(hMod, 'www_zfuwen_com_QQ_251578917_FreeKeyCode');
        @GetCodeResult := GetProcAddress(hMod, 'www_zfuwen_com_QQ_251578917_GetCode');
        @GetCodeFromURL:= GetProcAddress(hMod, 'www_zfuwen_com_QQ_251578917_GetCodeFromURL');
        nKeyCodeIndex:=InitKeyCode(0);
        if(nKeyCodeIndex>=0) then
        begin
          //showmessage('初始化成功'+IntToStr(nKeyCodeIndex));
        end
        else
        begin
          showmessage('初始化失败'+IntToStr(nKeyCodeIndex));
        end;
    end
  else
  begin
       showmessage('初始化失败');
  end;
end;

procedure TForm1.btnTestClick(Sender: TObject);
var
tick1:TTimeStamp;
tick2:TTimeStamp;
szfilename: WideString;
szstringFile:string;
retstr:Pointer;
startTime:TDateTime;
endTime:TDateTime;
retCount:Integer;
ShowRes: WideString;
cookie:string;   
outText:string;
begin
    szfilename:=edtInputfile.Text;
    startTime:=Now;
    szstringFile:=string(szfilename);
    szstringFile:=szstringFile;
    retstr:=AllocMem(100);
    if(CheckBox1.Checked) then
    begin
      retCount:=GetCodeFromURL(szstringFile,szstringFile,cookie,retstr,1,nKeyCodeIndex);
    end
   else
    begin
      retCount:=GetCodeResult(szstringFile,retstr,nKeyCodeIndex);
   end;
   image1.Picture.LoadFromFile('c:\www_zfuwen_com_Capture_Bitmap.bmp');

    endTime:=Now;
    tick1:= DateTimeToTimestamp(startTime);
    tick2:= DateTimeToTimestamp(endTime);
    outText:=string(retstr);
    ShowRes:=VarToWideStr(outText);
    if(retCount>0) then
    begin
       edtReg.Text:= ShowRes;//+'时间,'+IntToStr(tick2.Time-tick1.Time)+',当前时间:'+IntToStr(tick2.Time);
    end
    else
    begin
      showmessage('识别失败'+IntToStr(retCount));
    end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin   
    if(nKeyCodeIndex>=0) then
    begin
      FreeKeyCode(nKeyCodeIndex);
      nKeyCodeIndex:=-1;
    end;
end;

end.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Delphi中关于NMUDP控件的用法(原创)
Delphi制作DLL
Delphi2007 unicode
Delphi 的接口
Delphi回调函数及其使用
[转载]用delphi实现自动NAT(1)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服