重写VC++及C++的DLL库
重写VC++及C++的DLL库
已libshinecard.dll libshinecard.h libshinecard.lib为例
- 打开VC++6.0中打开
- 编写测试程序:需将libshinecard.h 添加引用 将libshinecard.lib加入工程连接中;如果是winform程序,则将#include <windows.h> 添加引用
- 新建Win32-Dynamic-Link Library 程序
a) 在libshinecard.cpp文件中://这里面是要重写的方法
extern "C" {
//add a func called by c#
//int __stdcall M100A_ReadMagcardDecode(HANDLE ComHandle, bool bHasMac_Addr, BYTE Mac_Addr, BYTE _track, DWORD *_DataLen,BYTE _BlockData[], char *RecordInfo);
LIBSHINECARD_API int shine_M100A_CheckCardPosition(HANDLE ComHandle,bool bHasMac_Addr, BYTE Mac_Addr,char * CardStates,char *RecordInfo)
{
printf("%s start\n", "shine_M100A_CheckCardPosition");
return M100A_CheckCardPosition(ComHandle,bHasMac_Addr, Mac_Addr,(BYTE*)CardStates,RecordInfo);
}
}
b) 再到libshinecard.h中
extern "C"
{
LIBSHINECARD_API int shine_M100A_CheckCardPosition(HANDLE ComHandle,bool bHasMac_Addr, BYTE Mac_Addr,char * CardStates,char *RecordInfo);
}