如何生成动态库和调试动态库?
使用 DEF 文件从 DLL 导出
https://msdn.microsoft.com/zh-cn/library/d91k01sh.aspx
如何:从 DLL 项目进行调试
https://msdn.microsoft.com/zh-cn/library/605a12zt.aspx
#ifndef FINGER_H
#define FINGER_H
#include <Windows.h>
#ifdef DLL_API
#define DLL_API extern "C" _declspec(dllimport)
#else
//#define DLL_API extern "C" _declspec(dllexport)
#define DLL_API _declspec(dllexport)
#endif // DLL_API
typedef struct _JsDevHANDLE
{
HANDLE hHandle; //设备句柄
int nDevType; //设备类型 USB-0 COM-1 UDisk-2
int iCom; //串口号
int iDevId; //设备Id
UINT32 dwPwd; //设备密码 0x00000000
UINT32 dwAddr; //设备地址 0xFFFFFFFF
char * sDevName; //设备信息 USB_No.0 Dev_COM1 UDisk_No.0
char * sMsg_CH; //硬件信息_CH 中文
char * sMsg_EN; //硬件信息_EN 英文
int iBaud_x; //波特率 $ 0 - 9600 1 - 19200 2 - 38400 3 - 57600 4 - 115200
int iPacketSize_x; //数据包大小 $ 0 - 32 1 - 64 2 - 128 3 - 256
int iSecureLev_x; //安全等级 $ 0 - 1 1 - 2 2 - 3 3 - 4 4 - 5
int iMbMax; //指纹库大小
char * ProductSN;
char * SoftwareVersion;
char * SensorName;
_JsDevHANDLE *next;//指向下一个的指针
// int nPackSize;
}JsDevHandle, *pJsDevHandle;
/*
参数:
pJsDevHandle * Device 打开的设备的指针
返回值:
0 成功,非 0 失败
功能描述:
打开并初始化设备,获取设备信息
*/
DLL_API int _stdcall HS_OpenDevice(pJsDevHandle* Device);
/*
参数:
pJsDevHandle * Device 要关闭的设备的指针
返回值:
0 成功,非 0 失败
功能描述:
打开并初始化设备,获取设备信息
*/
DLL_API int _stdcall HS_CloseDevice(pJsDevHandle Device);
/*
参数:
handle 设备句柄
返回值:
0 成功,非 0 失败
功能描述:
模块控制指纹传感器采集图像,保存到模块数据缓冲区,不上传指纹图像。
*/
DLL_API int _stdcall HS_GetImage(void* hHandle,unsigned int nAddr);
DLL_API int _stdcall HS_GetCardMessage(void *hHandle, unsigned int nAddr);
DLL_API int _stdcall HS_UpCardMessage(void *hHandle, unsigned int nAddr, unsigned char *mesgbuf, int *mesglen);
/*
参数:
handle 设备句柄
nAddr 设备编号
pImageData 接收数据缓冲区
iImageLength 接收的数据长度
返回值:
0 成功,非 0 失败
功能描述:
将模块中的指纹图像上传到上位机
*/
DLL_API int _stdcall HS_UpImage(void* hHandle,unsigned int nAddr,unsigned char* pImageData,int* iImageLength);
DLL_API int _stdcall HS_GenChar(void *hHandle, unsigned int nAddr, int iBufferID);
DLL_API int _stdcall HS_Match(void *hHandle, unsigned int nAddr, int* iScore1, int* iScore2 = 0, int *iScore3 = 0);
DLL_API int _stdcall HS_SetIOPin(void *hHandle, unsigned int nAddr, int IOPin, int SetIOPinMode);
DLL_API int _stdcall HS_Display(void *hHandle, unsigned int nAddr, unsigned char *desplayBuf);
DLL_API int _stdcall HS_UpChar(void *hHandle, unsigned int nAddr, int iBufferID, unsigned char* pTemplet, int* iTempletLength);
DLL_API int _stdcall HS_DownChar(void *hHandle, unsigned int nAddr, int iBufferID, unsigned char* pTemplet, int iTempletLength);
DLL_API int _stdcall HS_DownImage(void *hHandle, unsigned int nAddr, unsigned char *pImageData, int iLength);
DLL_API int _stdcall HS_ReadInfo(void *hHandle, unsigned int nAddr, int nPage, unsigned char* UserContent);
DLL_API int _stdcall HS_WriteInfo(void *hHandle, unsigned int nAddr, int nPage, unsigned char* UserContent);
DLL_API int _stdcall HS_SensorInit(void *hHandle, unsigned int nAddr);
DLL_API int _stdcall HS_GetDesc(void *hHandle, unsigned int nAddr, char pszDesc[1024]);
DLL_API int _stdcall HS_WritePrivateMemory(void *hHandle, unsigned int nAddr, unsigned int uBlockPage, UINT8 * memorycpybuf);
DLL_API int _stdcall HS_ReadPrivateMemory(void *hHandle, unsigned int nAddr, unsigned int uBlockPage, UINT8 * memorycpybuf);
//以iBufferID指定的缓冲区中的特征文件搜索整个或部分指纹库
DLL_API int _stdcall HS_Search(void *hHandle, unsigned int nAddr, int iBufferID, int *iMbAddress, int *piScore);
//将iBufferID指定的缓冲区中的特征文件储存到flash指纹库中
DLL_API int _stdcall HS_StoreChar(void *hHandle, unsigned int nAddr, int iBufferID, int iPageID);
//从flash指纹库中读取一个模板到ModelBuffer
DLL_API int _stdcall HS_LoadChar(void *hHandle, unsigned int nAddr, int iBufferID, int iPageID);
//PURPOSE: 读模版索引表
DLL_API int _stdcall HS_ReadIndexTable(void *hHandle, unsigned int nAddr, unsigned char* UserContent);
//删除flash指纹库中的一个特征文件
DLL_API int _stdcall HS_DelChar(void *hHandle, unsigned int nAddr, int PageID);
DLL_API int _stdcall HS_GetQualityScore(void * hHandle, unsigned int nAddr, unsigned char *pImageData, int *pScore);
#endif // FINGER_H
#include "stdafx.h"
#include "Finger.h"
#include "Finger\Protocol.h"
#pragma comment(lib,"Finger/ZAZAPIt.lib")
HANDLE zazHandle = NULL;
unsigned int zazAddr = 0xffffffff;
int zaziImageLength = 0;
unsigned char zazImageBuf[256 * 360];
int _stdcall HS_OpenDevice(pJsDevHandle * Device)
{
return ZAZOpenDeviceEx(&zazHandle, 2, 0, 9600, 2, 0);
}
int _stdcall HS_CloseDevice(pJsDevHandle Device)
{
return ZAZCloseDeviceEx(&zazHandle);
}
int _stdcall HS_GetImage(void * hHandle, unsigned int nAddr)
{
return ZAZGetImage(zazHandle, nAddr);
}
int _stdcall HS_GetCardMessage(void * hHandle, unsigned int nAddr)
{
return 0;
}
int _stdcall HS_UpCardMessage(void * hHandle, unsigned int nAddr, unsigned char * mesgbuf, int * mesglen)
{
return 0;
}
int _stdcall HS_UpImage(void * hHandle, unsigned int nAddr, unsigned char * pImageData, int * iImageLength)
{
return ZAZUpImage(zazHandle,nAddr,pImageData,iImageLength);
}
int _stdcall HS_GenChar(void * hHandle, unsigned int nAddr, int iBufferID)
{
return 0;
}
int _stdcall HS_Match(void * hHandle, unsigned int nAddr, int * iScore1, int * iScore2, int * iScore3)
{
return 0;
}
int _stdcall HS_SetIOPin(void * hHandle, unsigned int nAddr, int IOPin, int SetIOPinMode)
{
return 0;
}
int _stdcall HS_Display(void * hHandle, unsigned int nAddr, unsigned char * desplayBuf)
{
return 0;
}
int _stdcall HS_UpChar(void * hHandle, unsigned int nAddr, int iBufferID, unsigned char * pTemplet, int * iTempletLength)
{
return 0;
}
int _stdcall HS_DownChar(void * hHandle, unsigned int nAddr, int iBufferID, unsigned char * pTemplet, int iTempletLength)
{
return 0;
}
int _stdcall HS_DownImage(void * hHandle, unsigned int nAddr, unsigned char * pImageData, int iLength)
{
return 0;
}
int _stdcall HS_ReadInfo(void * hHandle, unsigned int nAddr, int nPage, unsigned char * UserContent)
{
return 0;
}
int _stdcall HS_WriteInfo(void * hHandle, unsigned int nAddr, int nPage, unsigned char * UserContent)
{
return 0;
}
int _stdcall HS_SensorInit(void * hHandle, unsigned int nAddr)
{
return 0;
}
int _stdcall HS_GetDesc(void * hHandle, unsigned int nAddr, char pszDesc[1024])
{
return 0;
}
int _stdcall HS_WritePrivateMemory(void * hHandle, unsigned int nAddr, unsigned int uBlockPage, UINT8 * memorycpybuf)
{
return 0;
}
int _stdcall HS_ReadPrivateMemory(void * hHandle, unsigned int nAddr, unsigned int uBlockPage, UINT8 * memorycpybuf)
{
return 0;
}
int _stdcall HS_Search(void * hHandle, unsigned int nAddr, int iBufferID, int * iMbAddress, int * piScore)
{
return 0;
}
int _stdcall HS_StoreChar(void * hHandle, unsigned int nAddr, int iBufferID, int iPageID)
{
return 0;
}
int _stdcall HS_LoadChar(void * hHandle, unsigned int nAddr, int iBufferID, int iPageID)
{
return 0;
}
int _stdcall HS_ReadIndexTable(void * hHandle, unsigned int nAddr, unsigned char * UserContent)
{
return 0;
}
int _stdcall HS_DelChar(void * hHandle, unsigned int nAddr, int PageID)
{
return 0;
}
int _stdcall HS_GetQualityScore(void * hHandle, unsigned int nAddr, unsigned char * pImageData, int * pScore)
{
return 0;
}
LIBRARY "海鑫科金指纹仪动态库"
EXPORTS
HS_OpenDevice @8
HS_CloseDevice @9
HS_GetImage @10
HS_GetCardMessage @11
HS_GenChar @12
HS_Match @13
HS_SetIOPin @14
HS_Display @15
HS_UpChar @16
HS_DownChar @17
HS_UpImage @18
HS_DownImage @19
HS_ReadInfo @21
HS_WriteInfo @22
HS_SensorInit @23
HS_Search @24
HS_StoreChar @25
HS_LoadChar @26
HS_ReadIndexTable @27
HS_DelChar @28
HS_GetDesc @29
HS_WritePrivateMemory @30
HS_ReadPrivateMemory @31
HS_GetQualityScore @33
HS_UpCardMessage @36
转载请注明出处并保持作品的完整性,谢谢