我已将DLL导入到我的程序中,并且有以下几个函数:
typedef int (*FEEDQ_CALLBACK) ( long nSD, long nQtype, long nNumber ) ;
typedef int (*CALLDISP_CALLBACK) ( AODFeedDispositionBase* CallDisposition );
typedef int (*SERVICE_STATUS_CALLBACK) ( long nSD, long nStatus ) ;
typedef int (*AUTH_SERVICE_CALLBACK) ( long nSD, char* sSDesc, long nSType ) ;
typedef int (*INBOUND_ABANDON_CALLBACK) ( long nSD, DCCProInboundDisposition* inbounCall ) ;
typedef int (*SESSION_STATUS_CALLBACK) ( long lTypeId, long lStatus ) ;
extern "C"
{
//Methods
AODFEEDAPI short Initialize(const char * sTenantName, const char * sUserID, const char * sPassword, AUTH_SERVICE_CALLBACK pAuthSrvFunc, SERVICE_STATUS_CALLBACK pSrvStatFunc, FEEDQ_CALLBACK pFeedQFunc, CALLDISP_CALLBACK pCallDispFunc, INBOUND_ABANDON_CALLBACK pInboundCallFunc, SESSION_STATUS_CALLBACK pSessionStatFunc = 0);
AODFEEDAPI short Close();
AODFEEDAPI short StopService( long nServiceID, long nQueueAction );
AODFEEDAPI short StartService(long nServiceID);
}
我想调用DLL中的Initialize()
函数。我对如何在回调函数中传递参数感到困惑。
答案 0 :(得分:0)
您不会将参数传递给回调。回调函数是您在自己的代码中定义的函数,然后提供给DLL,以便它可以在需要时调用它们,并将参数传递给您。例如:
int MyFeedQCallback( long nSD, long nQtype, long nNumber )
{
// do something...
}
int MyCallDispCallback( AODFeedDispositionBase* CallDisposition )
{
// do something...
}
int MyServiceStatusCallback( long nSD, long nStatus )
{
// do something...
}
int MyAuthServiceCallback( long nSD, char* sSDesc, long nSType )
{
// do something...
}
int MyInboundAbandonCallback( long nSD, DCCProInboundDisposition* inbounCall )
{
// do something...
}
int MySessionStatusCallback( long lTypeId, long lStatus )
{
// do something...
}
int main()
{
...
short ret = Initialize("tenant name", "user ID", "password", &AuthServiceCallback, &MyServiceStatusCallback, &MyFeedQCallback, &MyCallDispCallback, &MyInboundAbandonCallback, &MySessionStatusCallback);
...
long serviceID = ...;
StartService(serviceID);
...
StopService(serviceID, queueAction);
...
Close();
return 0;
}