一、DLL入口聲明
extern "C" __declspec(dllexport) int __stdcall fnDoFaceRecOut(char *fileFaceIni);
int __stdcall fnDoFaceRecOut(char *fileFaceIni)
{
AnsiString filename =fileFaceIni;
//....
int __stdcall fnDoFaceRecOut(char *fileFaceIni)
{
AnsiString filename =fileFaceIni;
//....
return 0;
}
}
二、測試 DLL代碼
void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{
HINSTANCE dd;
typedef int _stdcall (*deffnDoFaceRecGenMap)(char *fileFaceIni);
deffnDoFaceRecGenMap fnDoFaceRecGenMap;
AnsiString CurrentDir =ExtractFilePath(ParamStr(0))+"FaceRecDll.dll";
dd=::LoadLibrary(CurrentDir.c_str());
AnsiString fileFaceIni= "";
if (dd)
{
if (OpenDialog1->Execute())
{
fnDoFaceRecGenMap= (deffnDoFaceRecGenMap) GetProcAddress(dd,"fnDoFaceRecGenMap");
if (fnDoFaceRecGenMap)
{
lblMessage->Caption = "正在處理...";
Application-> ProcessMessages();
Caption=IntToStr(fnDoFaceRecGenMap(OpenDialog1->FileName.c_str()));
lblMessage->Caption = "處理完畢!";
}
}
}
}
{
HINSTANCE dd;
typedef int _stdcall (*deffnDoFaceRecGenMap)(char *fileFaceIni);
deffnDoFaceRecGenMap fnDoFaceRecGenMap;
AnsiString CurrentDir =ExtractFilePath(ParamStr(0))+"FaceRecDll.dll";
dd=::LoadLibrary(CurrentDir.c_str());
AnsiString fileFaceIni= "";
if (dd)
{
if (OpenDialog1->Execute())
{
fnDoFaceRecGenMap= (deffnDoFaceRecGenMap) GetProcAddress(dd,"fnDoFaceRecGenMap");
if (fnDoFaceRecGenMap)
{
lblMessage->Caption = "正在處理...";
Application-> ProcessMessages();
Caption=IntToStr(fnDoFaceRecGenMap(OpenDialog1->FileName.c_str()));
lblMessage->Caption = "處理完畢!";
}
}
}
}