1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
| #include <windows.h>
#include<iostream>
#include "MORPHO_User.h"
#include "MORPHO_Device.h"
#include "MORPHO_Database.h"
#include "MORPHO_Errors.h"
#include "MORPHO_FieldDescriptor.h"
using namespace std ;
#pragma comment(lib,"MORPHO_SDK.lib")
HMODULE hinstDLL;
int res;
char *mso_name,*mso_prop;
C_MORPHO_User u,nw,idf;
C_MORPHO_Database cdb;
C_MORPHO_Device c;
C_MORPHO_TemplateList tmp_list;
unsigned long t,nb_rcd,fld_ln,fld_uln,nb_user;
unsigned char *id,*fld_dt,*fld_nm,*fld_nwnm,*fld_udt;
T_MORPHO_FIELD_ATTRIBUTE fld_att;
unsigned short fld_sz;
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH : OutputDebugString("DLL_PROCESS_ATTACH\n"); break;
case DLL_THREAD_ATTACH : OutputDebugString("DLL_THREAD_ATTACH\n"); break;
case DLL_THREAD_DETACH : OutputDebugString("DLL_THREAD_DETACH\n"); break;
case DLL_PROCESS_DETACH : OutputDebugString("DLL_PROCESS_DETACH\n"); break;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
// Initialize
//
////////////////////////////////////////////////////////////////////////////////
extern "C" int WINAPI Initialize()
{
hinstDLL=LoadLibrary("MORPHO_SDK.dll");
if (hinstDLL == NULL) {
return 0;
}
return 1;
// Write here all the code you need to initialize the DLL
}
////////////////////////////////////////////////////////////////////////////////
// Release
//
////////////////////////////////////////////////////////////////////////////////
extern "C" void WINAPI Release()
{
FreeLibrary(hinstDLL);
// Write here all the code you need to free everything ...
}
////////////////////////////////////////////////////////////////////////////////
// opendevice
//
////////////////////////////////////////////////////////////////////////////////
extern "C" int WINAPI opendevice()
{
c=C_MORPHO_Device::C_MORPHO_Device();
res=c.OpenDevice(-1,115200);
return (res);
}
////////////////////////////////////////////////////////////////////////////////
// initUsb
//
////////////////////////////////////////////////////////////////////////////////
extern "C" int WINAPI initUsb()
{
res=c.InitUsbDevicesNameEnum(&t);
if(res==0)
{
int nb=(int)t;
return(nb);
}else
{
return(res);
}
}
////////////////////////////////////////////////////////////////////////////////
// getdatabase
//
////////////////////////////////////////////////////////////////////////////////
extern "C" int WINAPI getdatabase()
{
res=c.GetDatabase(0,cdb);
return(res);
}
////////////////////////////////////////////////////////////////////////////////
// getnbrrecord
//
////////////////////////////////////////////////////////////////////////////////
extern "C" int WINAPI getnbrrecord()
{
res=cdb.GetNbUsedRecord(nb_rcd);
if(res==0)
{
int nbr=(int)nb_rcd;
return(nbr);
}else
{
return(res);
}
}
////////////////////////////////////////////////////////////////////////////////
// getuser
//
////////////////////////////////////////////////////////////////////////////////
extern "C" int WINAPI getuser(int id)
{
unsigned char reg[50];
sprintf((char*)reg, "%i", id);
res=cdb.GetUser(MORPHO_USER_ID_MAXLEN,reg,u);
return(res);
}
////////////////////////////////////////////////////////////////////////////////
// enroll
//
////////////////////////////////////////////////////////////////////////////////
extern "C" int WINAPI enroll()
{
res=u.Enroll(0,0x01,MORPHO_PK_COMP,0,NULL,NULL);
return(res);
}
////////////////////////////////////////////////////////////////////////////////
// identify
//
////////////////////////////////////////////////////////////////////////////////
extern "C" int WINAPI identify()
{
res=cdb.Identify(0x11,MORPHO_FAR_5,0,NULL,NULL,idf);
if(res==0)
{
res=idf.GetField(0,fld_uln,fld_udt);
int nv=atoi((char*)fld_udt);
return(nv);
}else{
return(res);
}
} |
Partager