CreatDLL.CPP
上传用户:hyb6888
上传日期:2016-01-24
资源大小:5186k
文件大小:3k
- // dll.cpp : Defines the entry point for the DLL application.
- //
- #include "stdafx.h"
- #include "windows.h"
- #include "windowsx.h"
- #include "stdio.h"
- #include "tool.h"
- #define HOOKLIBAPI _declspce(dllexport)
- #include "CreateLib.h"
- #include "libarryOut.h"
- #define MYLIBAPI extern "C" __declspec(dllexport)
- libarryOut Mainloadlib;
- //输出全部代码
- MYLIBAPI BOOL outsource (char *Code,char *CodeSource,long base, long goldeNum, long goldeLen)
- {
- libarryOut myloadlib;
- int ret;
- // MessageBox(0,CodeSource,0,0);
- ret=myloadlib.loadChiLib(Code,base, goldeNum, goldeLen);//编码装入
- if (ret==0)
- myloadlib.Outsource(CodeSource);
- return 0;
- }
- //采用指向指针的指针以便VB可以带出数据。
- MYLIBAPI BOOL ChissToCode (char *MainCodeLibName,char *chiss,char **codess)
- {
- Mainloadlib.ChissToCode(MainCodeLibName,chiss,*codess);
- return 0;
- }
- //由中文串到英文代码
- MYLIBAPI BOOL ChissToCodeC (char *MainCodeLibName,char *chiss,char *codess)
- {
- Mainloadlib.ChissToCode(MainCodeLibName,chiss,codess);
- return 0;
- }
- //输出主代码
- MYLIBAPI BOOL OutsourceOne (char *Code,char *CodeSource,long base, long goldeNum, long goldeLen)
- {
- libarryOut myloadlib;
- int ret;
- // MessageBox(0,CodeSource,0,0);
- ret=myloadlib.loadChiLib(Code,base, goldeNum, goldeLen);//编码装入
- if (ret==0)
- myloadlib.OutsourceOne(CodeSource);
- return 0;
- }
- //建立库
- MYLIBAPI BOOL creat(char *CodeSource,char *userdefine,char *ExCodeSource,char *Code,long base, long goldeNum, long goldeLen)
- {
- CreateLib creat;
- libarryOut myloadlib;
- char ss[100];
- //MessageBox(0,"start","creat",0);
- if(creat.CreatChiLib(CodeSource,userdefine,ExCodeSource,Code, base, goldeNum, goldeLen)==0){
- //下面的测试生成的代码
- if(myloadlib.loadChiLib(Code, base, goldeNum, goldeLen)==-1)
- return 0;
- strcpy(ss,myloadlib.EntoCh("aa"));//由代码获得
- if(strlen(ss))
- MessageBox(0,ss,"ddga取词验证正确",0);
- else
- {
- MessageBox(0,"错误原因有:n1、编码与汉字串之间无空格n2、编码长度大于4个n3、编码为空。","取词验证错误",0);
- }
- }
- return 0;
- }
- //下面的为不进行测试,0表示成功
- MYLIBAPI BOOL creatNotest(char *CodeSource,char *userdefine,char *ExCodeSource,char *Code,long base, long goldeNum, long goldeLen)
- {
- CreateLib temcreat;
- int ret ;
- //MessageBox(0,"creatNotest","start",0);
- if(temcreat.CreatChiLib(CodeSource,userdefine,ExCodeSource,Code, base, goldeNum, goldeLen)==0)
- ret= 0;
- else
- ret= 1;
- return ret;
- }
- //测试库
- MYLIBAPI long TestLib(char *Code,long base, long goldeNum, long goldeLen,char *enchar,long showmsg,char **retstr)
- {
- libarryOut myloadlib;
- char ss[1001]="";
- //下面的测试生成的代码
- if(myloadlib.loadChiLib(Code, base, goldeNum, goldeLen)==-1)
- return 0;
- if(strlen(enchar)>0)
- strcpy(ss,myloadlib.EntoCh(enchar));//由代码获得
- ss[1000]=0;
- // MessageBox(0,ss,"ss",0);
- strcpy(*retstr,ss);//由代码获得
- if(showmsg==1){
- if(strlen(ss))
- MessageBox(0,ss,"取词验证正确",0);
- else
- {
- MessageBox(0,"错误原因有:n1、编码与汉字串之间无空格n2、编码长度大于4个n3、编码为空。","取词验证错误",0);
- }
- }
- return 1;
- }
- //下面的为不进行测试,0表示成功
- MYLIBAPI long ToolTranChar(char *fileName,long num,char *cc,char *tranCh)
- {
- tool lctool;
- lctool.TranChar(fileName,num,cc,tranCh);
- return 0;
- }