C++動態(tài)加載donsee32.dll方法
C++動態(tài)加載donsee32.dll方法,不依賴于donsee32.h和donsee32.lib文件。
void CtestDemoDlg::OnBnClickedButton4()
{
HINSTANCE g_hCtrlInstance;
g_hCtrlInstance = LoadLibrary("donsee32.dll"); //加載dll
if (!g_hCtrlInstance)
{
FreeLibrary(g_hCtrlInstance);
ShowInfo("加載donsee32.dll失??!");
return;
}
typedef long(_stdcall* fpDonsee_Open)(char*);//宏定義函數(shù)指針類型,輸出接口,定義函數(shù)指針
fpDonsee_Open Donsee_Open = (fpDonsee_Open)GetProcAddress(g_hCtrlInstance, "Donsee_Open");//函數(shù)指針聲明,聲明變量
typedef long(_stdcall* fpDonsee_Beep)();//蜂鳴
fpDonsee_Beep Donsee_Beep = (fpDonsee_Beep)GetProcAddress(g_hCtrlInstance, "Donsee_Beep");
typedef long(_stdcall* fpDonsee_ReadIDCard)(int, char*, IDINFO*, char*);//讀身份證
fpDonsee_ReadIDCard Donsee_ReadIDCard = (fpDonsee_ReadIDCard)GetProcAddress(g_hCtrlInstance, "Donsee_ReadIDCard");
if (Donsee_Open == NULL || Donsee_Beep == NULL || Donsee_ReadIDCard==NULL)
{
ShowInfo("加載Dll函數(shù)失??!");
FreeLibrary(g_hCtrlInstance);
return;
}
long t_nRe;
t_nRe = Donsee_Open("USB");
if (t_nRe != 0)
{
FreeLibrary(g_hCtrlInstance);
ShowInfo("打開讀卡器失??!");
return;
}
//讀身份證
char t_arrMsg[256];
char t_szPicPath[256] = "IDphoto.jpg";
CString t_strTemp;
IDINFO idInfo;
memset(&idInfo, 0, sizeof(IDINFO));
t_nRe = Donsee_ReadIDCard(1, t_szPicPath, &idInfo, t_arrMsg);
if (t_nRe != 0)
{
FreeLibrary(g_hCtrlInstance);
ShowInfo("身份證讀取失敗");
return;
}
Donsee_Beep();
ShowInfo("身份證讀取成功:");
ShowInfo("證件類型標識:", idInfo.certType);
ShowInfo("姓名:", idInfo.name);
ShowInfo("性別:", idInfo.sex);
ShowInfo("證件號碼:", idInfo.number);
ShowInfo("出生日期:", idInfo.birthday);
FreeLibrary(g_hCtrlInstance);
}