资源简介
亦思验证码C++调用封装库,支持网络图片,本地图片,内存图片的识别。在官方的dll实例中只有VB、delp、易语言的例子,没有VC的,今天刚好用到,简单封装了下,分享下,讨论下:QQ:103.626,571
//////////////////调用示例//////////////////////
int item = 3;
cVcode::init("all.fc", "123456");
//网络地址验证码
CString code = cVcode::getNetCode("http://www.xxx.net/UsreAdmin/HouseMgr/validatecode.asp", item);
wcout<<code.GetString()<<endl;
//本地验证码
CString code2 = cVcode::getLocalCode("c:/yfwcode.bmp", item);
wcout<<code2.GetString()<<endl;
//内存中的验证码
HttpLib lib;
CMemFile file;
lib.getFile("http://www.xxx.net/UsreAdmin/HouseMgr/validatecode.asp", &file);
CString code3 = cVcode::getMemCode(file, item);
wcout<<code3.GetString()<<endl;

代码片段和文件信息
#include “StdAfx.h“
#include “cVcode.h“
using namespace std;
void cVcode::exit()
{
isInit = FALSE;
FreeLibrary(hdll);
}
BOOL cVcode::init( char * libPath char * pwd )
{
try{
hdll = LoadLibrary(L“ycode.dll“);
loadcode = (lpLoadCode)GetProcAddress(hdll “loadcode“);
recognition = (lpRecognition)GetProcAddress(hdll “Recognitiond“);
//加载验证码库
loadcode(00libPathpwd);
isInit = TRUE;
return TRUE;
}catch(exception &e){
cout<<“Exception:“< return FALSE;
}
}
CString cVcode::getNetCode( CString &picUrl int &itemId )
{
if (!isInit) return ““;
USES_CONVERSION;
char * _picUrl = T2A(picUrl);
try{
char * code = recognition(itemId 0 0 _picUrl ““);
CString rst;
rst.Format(L“%s“ A2T(code));
return rst;
}catch(exception &e){
cout<<“Exception:“< return ““;
}
}
CString cVcode::getLocalCode( CString &picPath int &itemId )
{
if (!isInit) return ““;
USES_CONVERSION;
char * _picPath = T2A(picPath);
try{
char * code = recognition(itemId 0 0 ““ _picPath);
CString rst;
rst.Format(L“%s“ A2T(code));
return rst;
}catch(exception &e){
cout<<“Exception:“< return ““;
}
}
CString cVcode::getMemCode( CMemFile &file int &itemId )
{
if (!isInit) return ““;
USES_CONVERSION;
try{
int dataLen = file.GetLength();
byte * dataByte = new byte[dataLen];
file.SeekToBegin();
file.Read(dataByte dataLen);
char * code = recognition(itemId (long)dataByte dataLen ““ ““);
delete [] dataByte;
CString rst;
rst.Format(L“%s“ A2T(code));
return rst;
}catch(exception &e){
cout<<“Exception:“< return ““;
}
}
lpRecognition cVcode::recognition = NULL;
lpLoadCode cVcode::loadcode = NULL;
HINSTANCE cVcode::hdll = NULL;
BOOL cVcode::isInit = FALSE;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1373 2011-01-21 18:50 cVcode.h
文件 1893 2011-01-21 18:39 cVcode.cpp
文件 595 2011-01-21 18:58 使用例子.txt
----------- --------- ---------- ----- ----
3861 3
相关资源
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- MFC数字钟(基于VC6.0)
- 安科瑞智能电能表MODBUS通讯程序 VC6
- VC++MFC小游戏实例教程(实例)+MFC类库
- VC6LineNumberAddin.dll
- 用VC6.0实现多边形扫描线填充算法
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- VC助手 VC6.0助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
评论
共有 条评论