下载一个async32 ---- 一个串口控件,有DEMO程序;
可以搜索或到http://202.96.70.228/cakk/delphi/delphi.htm看看。
以下是C和DELPHI 的一些对应
unit Unit_dll;
interface
type
TZDP=record
hres:integer;
zres:integer;
direct:integer;
flag:char;
end;
CMD=record
PkgId:byte;
Address:array[0..1] of byte;
PkgLen:byte;
PkgCnt:array[0..127] of byte;
Jyh:array[0..1] of byte;
end;
SCMD=record
sPkgId:byte;
sAddress:array[0..1] of byte;
sPkgLen:byte;
sPkgCnt:array[0..127] of byte;
sJyh:array[0..1] of byte;
end;
TarrayImg=array[0..127,0..127] of byte;
ptArrayImg=^tarrayImg;
Tarray1=array[0..7]of byte;
ptarray1=^tarray1;
Tarray2=array of TZDP;
ptarray2=^tarray2;
Tarray3=array[0..127]of byte;
ptarray3=^tarray3;
Tarray4=array[0..255]of byte;
ptarray4=^tarray4;
PTbyte=^byte;
PTCmd=^cmd;
PTscmd=^scmd;
PTinteger=^integer;
PTboolean=^boolean;
function WriteBMP(name:string;img:tarrayimg): byte;cdecl;external 'io_dll.dll';
function InitCom(comport:integer) :boolean;cdecl;external 'io_dll.dll';
function ReleaseCom(comport:integer) :boolean;cdecl;external 'io_dll.dll';
function GetPkgByte(comport:integer;Tranbyte
Tbyte) :integer;cdecl;external 'io_dll.dll';
function SendPkgByte(comport:integer;Tranbyte:byte) :integer;cdecl;external 'io_dll.dll';
function GetPackage(comport:integer;cmd
TCmd) :integer;cdecl;external 'io_dll.dll';
function SendPackage(comport:integer;SCMD:scmd) :integer;cdecl;external 'io_dll.dll';
function SensorReset(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorStatus(comport:integer;St0,St1
Tbyte) :integer;cdecl;external 'io_dll.dll';
function SensorEnroll(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorGenTzz(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorDownMb(comport:integer; nummb:integer; mb
tarray2;DampMbLock:integer) :integer;cdecl;external 'io_dll.dll';
function SensorDownTz(comport:integer;numtzd:integer; tzd
tarray2;DampFinger
tinteger) :integer;cdecl;external 'io_dll.dll';
function SensorUpMb(comport:integer;nummb
tinteger;mb
tarray2;DampMbLock
tinteger) :integer;cdecl;external 'io_dll.dll';
function SensorUpTz(comport:integer;numtzd
tinteger; tzd
tarray2;DampFinger
tinteger) :integer;cdecl;external 'io_dll.dll';
function SensorStore(comport:integer;address:integer) :integer;cdecl;external 'io_dll.dll';
function SensorLdBuf(comport:integer;address:integer) :integer;cdecl;external 'io_dll.dll';
function SensorVerify(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorQuickSearch(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorSearch(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorEraseOne(comport:integer;address:integer) :integer;cdecl;external 'io_dll.dll';
function SensorEraseAll(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorGenImg(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorUpImg(comport:integer;image
TarrayImg;DampFinger
tinteger) :integer;cdecl;external 'io_dll.dll'; //300pix/inch,0-180 gray
function SensorSetAddr(comport:integer; Addr0,Addr1:byte) :integer;cdecl;external 'io_dll.dll';
function SensorSignature(comport:integer;Sign
tarray3) :integer;cdecl;external 'io_dll.dll';
function SensorSecuLevel(comport:integer;Level:byte) :integer;cdecl;external 'io_dll.dll';
function SensorDeviceKey(comport:integer;OldPwd,NewPwd
tarray1) :integer;cdecl;external 'io_dll.dll';
function SensorFree(comport:integer) :integer;cdecl;external 'io_dll.dll';
//function SensorLoadPage(comport:integer;cc
tarray4) :integer ;cdecl;external 'io_dll.dll';
//function SensorStorePage(comport:integer;cc
tarray4) :integer;cdecl;external 'io_dll.dll';
//function YanZ(comport:integer;cont
tboolean) :integer;cdecl;external 'io_dll.dll';
//function DenL(comport:integer;id:integer;cont
tboolean) :integer;cdecl;external 'io_dll.dll';
//function Image(comport:integer;Image:array of byte;cont
tboolean) :integer;cdecl;external 'io_dll.dll';
//function MoBan(comport:integer;id:integer;cont
tboolean) :integer;cdecl;external 'io_dll.dll';
//function Verif(comport:integer;id:integer;cont
tboolean) :integer;cdecl;external 'io_dll.dll';
//function SearchC(comport:integer;cont
tboolean):integer;cdecl;external 'io_dll.dll';
//***********For SM-2A**************//
function SensorHighSet(comport:integer; dmperror:char;drawlevel,door,mbdoor,grade,intquick, frd:integer):integer;cdecl;external 'io_dll.dll';
function SensorLowSet(comport:integer; dmperror:char;drawlevel,door,mbdoor,grade,intquick, frd:integer):integer;cdecl;external 'io_dll.dll';
//************************************//
implementation
end.
#ifndef _PROTOCOL_
#define _PROTOCOL_
/*******************************************************/
/*---------------------- response----------------------*/
#define mRight 0x81
#define mReIn 0x82
#define mEot 0x83
#define mBusy 0x84 //Module response
#define hRight 0x81
#define hReIn 0x82
#define hEot 0x83 //Host response
/*---------------------- command----------------------*/
#define Reset 0x00
#define Status 0x01
#define Enroll 0x03
#define GenTzz 0x04
#define DownMb 0x05
#define DownTz 0x06
#define UpMb 0x07
#define UpTz 0x08
#define Store 0x09
#define LdBuf 0x0a
#define Verify 0x0b
#define QuickSearch 0x0c
#define Search 0x0d
#define EraseOne 0x0e
#define EraseAll 0x0f
#define GenImg 0x10
#define UpImg 0x11
#define SetAddr 0x12
#define Signature 0x13
#define SecuLevel 0x14
#define DeviceKey 0x15
#define Free 0x16
#define StorePage 0x17
#define LoadPage 0x18
#define SysLowSet 0x81
#define SysHighSet 0x82
/*--------------------PkgID----------------------*/
#define Cmd 0x1<<0
#define Data 0x1<<1
#define EndData 0x1<<3
struct TZDP
{
int hres;
int zres;
int direct;
char flag;
};
struct CMD
{
unsigned char PkgId;
unsigned char Address[2];
unsigned char PkgLen;
unsigned char PkgCnt[128];
unsigned char Jyh[2];
};
struct SCMD
{
unsigned char sPkgId;
unsigned char sAddress[2];
unsigned char sPkgLen;
unsigned char sPkgCnt[128];
unsigned char sJyh[2];
};
HANDLE HCOM[8];
/*--------------------function---------------------*/
bool InitCom(int comport);
void ReleaseCom(int comport);
int GetPkgByte(int comport,unsigned char *TranChar);
int SendPkgByte(int comport,unsigned char TranChar);
int GetPackage(int comport,CMD *cmd);
int SendPackage(int comport,SCMD scmd);
int SensorReset(int comport);
int SensorStatus(int comport,unsigned char* St0,unsigned char* St1);
int SensorEnroll(int comport);
int SensorGenTzz(int comport);
int SensorDownMb(int comport,int nummb,TZDP mb[],int DampMbLock);
int SensorDownTz(int comport,int numtzd,TZDP tzd[],int DampFinger);
int SensorUpMb(int comport,int* nummb,TZDP mb[],int* DampMbLock);
int SensorUpTz(int comport,int* numtzd,TZDP tzd[],int* DampFinger);
int SensorStore(int comport,int address);
int SensorLdBuf(int comport,int address);
int SensorVerify(int comport);
int SensorQuickSearch(int comport);
int SensorSearch(int comport);
int SensorEraseOne(int comport,int address);
int SensorEraseAll(int comport);
int SensorGenImg(int comport);
int SensorUpImg(int comport,unsigned char image[128][128],int* DampFinger); //300pix/inch,0-180 gray
int SensorSetAddr(int comport,unsigned char Addr0,unsigned char Addr1);
int SensorSignature(int comport,unsigned char Sign[128]);
int SensorSecuLevel(int comport,unsigned char Level);
int SensorDeviceKey(int comport,unsigned char OldPwd[8],unsigned char NewPwd[8]);
int SensorFree(int comport);
int SensorLoadPage(int comport,unsigned char cc[256]) ;
int SensorStorePage(int comport,unsigned char cc[256]);
int YanZ(int comport,bool *cont);
int DenL(int comport,int id,bool *cont);
int SensorHighSet(int comport,char dmperror,int drawlevel,int door,int mbdoor,int grade,int intquick,int frd);
int SensorLowSet(int comport,char dmperror,int drawlevel,int door,int mbdoor,int grade,int intquick,int frd);
unsigned char WriteBMP(char* file,unsigned char Input[128][128]);
/*********************************************************************/
#endif
这是一个将字符转换成为可以显示的HEX格式的2个char型数据;;
function TfrmMain.char2hex(ch:char):string;
begin
result:=shuzu[(integer(ch) div 16)+1];
result:=result+shuzu[(integer(ch) mod 16)+1];
end;
function TfrmMain.Hex2BCD(BCDByte:WORD):WORD;
begin
Result:=(BCDByte div 10)*16+ BCDByte mod 10;
END;
以上仅仅供参考。。。