DELPHI 如何把函数指针传给C++的DLL内
供应商提供的是C++的DLL。跟DEMO。
以下是供应商的DLL接口:
回调函数的指针类型
typedef void (*AgentEventCallback)(AgentNotifyType notifyType, void* dataPtr);
初始化函数
DllExport AGENT_RESULT AgentInitialize(
const bool isCompressed,
const char *pszHost,
const bool bIsDomain,
const char *pszPort,
const char *pszEnterpriseID,
const char* pszDNIS,
AgentEventCallback callbackFunc);
调用的时候是
void CallbackFunc(AgentNotifyType notifyType, void* dataPtr)
{
}
if (AgentInitialize(false, gGlsHost.c_str(), gIsDomain, gGlsPort.c_str(), gEnterpriseID.c_str(), gDNIS.c_str(), CallbackFunc) != 1)
{
ShowLog("初始化失败!");
}
//===================================================================
关键是最后一个参数: AgentEventCallback callbackFunc); 他是一个函数的指针。
我在DELPHI里面定义了这个类型;
type TAgentEventCallback = procedure(notifyType :AgentNotifyType; dataPtr :pointer); stdcall;
调用的时候就是:
先声明:
var
callbackFunc : TAgentEventCallback ;
然后调用:
AgentInitialize(isCompressed,pszHostgls,bIsDomain,pszPortgls,pszEnterpriseID,pszDNIS,callbackFunc);
之后呢??不会写了。
个人理解是 这个DLL需要我传一个函数的指针进去。
函数的指针我传进去了。。可是函数的实现我还没有写啊!!
在线等。。各位老大。分数不够。。。SHOWHAND。