Click here to Skip to main content
15,066,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

i know this question is somewhat duplicated however i have tried the solutions i have seen so far to no avail so i am looking to your for help.

I have an Unmanaged DLL (i do not have the source for the DLL only the DLL, LIB and Header file (C++). I have attempted to write a C++/CLR wrapper but i have no skills in C++ and really struggling.

The class has several entry points (but looking at the header file these functions are inside a class) but i am not sure how the CPP file is performing the function.

The documentation from the provider doesnt not show any thing regarding the construction of the class / functions or if anything needs doing before calling the functions directly.

This is the DllImport that i am trying to use to call teh InsertExclusion entry point but i keep getting the error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

VB
<DllImport("AGDGatewayInterface.dll", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="?InsertExclusion@CAGDGatewayInterface@@QAE?AW4AGDClientError@@JPADJ00@Z")> _
Public Sub InsertExclusion(
                                    lExclusionType As Integer,
                                   <MarshalAs(UnmanagedType.LPStr)> ByRef szValue As String,
                                    lAppId As Integer,
                                   <MarshalAs(UnmanagedType.LPStr)> ByRef szStartDate As String,
                                   <MarshalAs(UnmanagedType.LPStr)> ByRef szEndate As String
                               )
End Sub

        Dim val1 As String, val2 As String, val3 As String, val4 As Long, val5 As Long
        val1 = "012345678910"
        val2 = "2016-06-08 00:00:00"
        val3 = "2016-06-08 23:59:59"
        val4 = 3
        val5 = 0

        Call InsertExclusion(val4, val1, val5, val2, val3)


My question is really is that i do not know where i am going wrong to try and call this function or how if i need to call the CAGDGatewayInterface Class and then call the function from within the class?

Please can someone help me create the wrapper or get the right DllImports right for this please?

Entry Points in Unmanged C++ DLL.
??0CAGDGatewayCallBack@@QAE@ABV0@@Z
??0CAGDGatewayCallBack@@QAE@XZ
??0CAGDGatewayInterface@@QAE@PADPAVCAGDGatewayCallBack@@0H0H@Z
??1CAGDGatewayInterface@@QAE@XZ
??4CAGDGatewayCallBack@@QAEAAV0@ABV0@@Z
??4CAGDGatewayInterface@@QAEAAV0@ABV0@@Z
??_7CAGDGatewayCallBack@@6B@
?CallBackUpdate@CAGDGatewayInterface@@QAE?AW4AGDClientError@@W4AGDCallbackUpdateType@@HHHPAD1@Z
?CallBackUpdateAck@CAGDGatewayCallBack@@UAEXW4AGDCallbackUpdateType@@HHHPAD1JAAUAGDGatewayDateTime@@@Z
?CallCleared@CAGDGatewayCallBack@@UAEXJJJJAAUAGDGatewayDateTime@@@Z
?DeleteAllExclusions@CAGDGatewayInterface@@QAE?AW4AGDClientError@@XZ
?DeleteExclusion@CAGDGatewayInterface@@QAE?AW4AGDClientError@@JPADJ@Z
?DeleteRecordSet@CAGDGatewayInterface@@AAE_NXZ
?Disconnect@CAGDGatewayInterface@@AAEXXZ
?Disposition@CAGDGatewayCallBack@@UAEXJJJJAAUUserDefinedData@@AAUAGDGatewayDateTime@@@Z
?EndSession@CAGDGatewayInterface@@QAE?AW4AGDClientError@@XZ
?ExecuteCCDown@CAGDGatewayInterface@@QAEXXZ
?ExecuteCCTimeOut@CAGDGatewayInterface@@QAEXXZ
?ExecuteCCUp@CAGDGatewayInterface@@QAEXXZ
?FoundAgent@CAGDGatewayCallBack@@UAEXJJJPADAAUAGDGatewayDateTime@@@Z
?GetInterface@CAGDGatewayCallBack@@QAEPAXXZ
?GetMediaList@CAGDGatewayInterface@@QAE?AW4AGDClientError@@JJ@Z
?InsertExclusion@CAGDGatewayInterface@@QAE?AW4AGDClientError@@JPADJ00@Z
?InsertExclusionWithoutNotify@CAGDGatewayInterface@@QAE?AW4AGDClientError@@JPADJ00@Z
?KillAllCallsInService@CAGDGatewayInterface@@QAE?AW4AGDClientError@@J@Z
?KillCall@CAGDGatewayInterface@@QAE?AW4AGDClientError@@JJJ@Z
?KillMediaCall@CAGDGatewayInterface@@QAE?AW4AGDClientError@@J@Z
?LoginToCC@CAGDGatewayInterface@@AAE_NPADH@Z
?MediaCallGone@CAGDGatewayCallBack@@UAEX_NJ@Z
?MediaListCall@CAGDGatewayCallBack@@UAEXJJJJJJJ@Z
?NewCall@CAGDGatewayInterface@@QAE?AW4AGDClientError@@JAAUUserDefinedData@@J@Z
?NewCallAck@CAGDGatewayCallBack@@UAEXJJJJJAAUAGDGatewayDateTime@@@Z
?NewCallAgent@CAGDGatewayInterface@@QAE?AW4AGDClientError@@JAAUUserDefinedData@@JPAD@Z
?NotifyCCOfExclusionInsert@CAGDGatewayInterface@@QAE?AW4AGDClientError@@XZ
?PrintInBoundPacket@CAGDGatewayInterface@@AAEXPAX@Z
?PrintOutGoingPacket@CAGDGatewayInterface@@AAEXPAX@Z
?ProcessPacket@CAGDGatewayInterface@@AAEXPAX@Z
?ReRoute@CAGDGatewayCallBack@@UAEXJJJJJJAAUUserDefinedData@@AAUAGDGatewayDateTime@@@Z
?SendNewCallPacket@CAGDGatewayInterface@@AAE?AW4AGDClientError@@PAXJ@Z
?SendPacket@CAGDGatewayInterface@@AAE?AW4AGDClientError@@PAXJ@Z
?SendTECommand@CAGDGatewayInterface@@AAE_NHPAXHH@Z
?ServiceStatus@CAGDGatewayCallBack@@UAEXJJAAUAGDGatewayDateTime@@@Z
?SetInterface@CAGDGatewayCallBack@@QAEXPAX@Z
?StartSession@CAGDGatewayInterface@@QAE?AW4AGDClientError@@XZ
?UpdateCallData@CAGDGatewayInterface@@QAE?AW4AGDClientError@@JJJAAUUserDefinedData@@@Z
?UpdateCallDataAck@CAGDGatewayCallBack@@UAEXJJJJAAUAGDGatewayDateTime@@@Z
?WinSockInit@@YA_NXZ


UNDName of Entry Points
 1    0 00001080 public: __thiscall CAGDGatewayCallBack::CAGDGatewayCallBack(class CAGDGatewayCallBack const &)
 2    1 00001050 public: __thiscall CAGDGatewayCallBack::CAGDGatewayCallBack(void)
 3    2 00001D10 public: __thiscall CAGDGatewayInterface::CAGDGatewayInterface(char *,class CAGDGatewayCallBack *,char *,int,char *,int)
 4    3 00001E20 public: __thiscall CAGDGatewayInterface::~CAGDGatewayInterface(void)
 5    4 000010A0 public: class CAGDGatewayCallBack & __thiscall CAGDGatewayCallBack::operator=(class CAGDGatewayCallBack const &)
 6    5 000010C0 public: class CAGDGatewayInterface & __thiscall CAGDGatewayInterface::operator=(class CAGDGatewayInterface const &)
 7    6 0002A370 const CAGDGatewayCallBack::`vftable'
 8    7 00002B30 public: enum AGDClientError __thiscall CAGDGatewayInterface::CallBackUpdate(enum AGDCallbackUpdateType,int,int,int,char *,char *)
 9    8 00001A50 public: virtual void __thiscall CAGDGatewayCallBack::CallBackUpdateAck(enum AGDCallbackUpdateType,int,int,int,char *,char *,long,struct AGDGatewayDateTime &)
10    9 00001930 public: virtual void __thiscall CAGDGatewayCallBack::CallCleared(long,long,long,long,struct AGDGatewayDateTime &)
11    A 00003850 public: enum AGDClientError __thiscall CAGDGatewayInterface::DeleteAllExclusions(void)
12    B 000039B0 public: enum AGDClientError __thiscall CAGDGatewayInterface::DeleteExclusion(long,char *,long)
13    C 000026D0 private: bool __thiscall CAGDGatewayInterface::DeleteRecordSet(void)
14    D 00001430 private: void __thiscall CAGDGatewayInterface::Disconnect(void)
15    E 00001B90 public: virtual void __thiscall CAGDGatewayCallBack::Disposition(long,long,long,long,struct UserDefinedData &,struct AGDGatewayDateTime &)
16    F 000031A0 public: enum AGDClientError __thiscall CAGDGatewayInterface::EndSession(void)
17   10 00001570 public: void __thiscall CAGDGatewayInterface::ExecuteCCDown(void)
18   11 000016B0 public: void __thiscall CAGDGatewayInterface::ExecuteCCTimeOut(void)
19   12 000017E0 public: void __thiscall CAGDGatewayInterface::ExecuteCCUp(void)
20   13 00001AC0 public: virtual void __thiscall CAGDGatewayCallBack::FoundAgent(long,long,long,char *,struct AGDGatewayDateTime &)
21   14 00001070 public: void * __thiscall CAGDGatewayCallBack::GetInterface(void)
22   15 00002100 public: enum AGDClientError __thiscall CAGDGatewayInterface::GetMediaList(long,long)
23   16 00003C80 public: enum AGDClientError __thiscall CAGDGatewayInterface::InsertExclusion(long,char *,long,char *,char *)
24   17 00003B40 public: enum AGDClientError __thiscall CAGDGatewayInterface::InsertExclusionWithoutNotify(long,char *,long,char *,char *)
25   18 00002FA0 public: enum AGDClientError __thiscall CAGDGatewayInterface::KillAllCallsInService(long)
26   19 00002E90 public: enum AGDClientError __thiscall CAGDGatewayInterface::KillCall(long,long,long)
27   1A 00002200 public: enum AGDClientError __thiscall CAGDGatewayInterface::KillMediaCall(long)
28   1B 00003330 private: bool __thiscall CAGDGatewayInterface::LoginToCC(char *,int)
29   1C 00001CB0 public: virtual void __thiscall CAGDGatewayCallBack::MediaCallGone(bool,long)
30   1D 00001C50 public: virtual void __thiscall CAGDGatewayCallBack::MediaListCall(long,long,long,long,long,long,long)
31   1E 00002C60 public: enum AGDClientError __thiscall CAGDGatewayInterface::NewCall(long,struct UserDefinedData &,long)
32   1F 000019F0 public: virtual void __thiscall CAGDGatewayCallBack::NewCallAck(long,long,long,long,long,struct AGDGatewayDateTime &)
33   20 00002D70 public: enum AGDClientError __thiscall CAGDGatewayInterface::NewCallAgent(long,struct UserDefinedData &,long,char *)
34   21 00002020 public: enum AGDClientError __thiscall CAGDGatewayInterface::NotifyCCOfExclusionInsert(void)
35   22 00001260 private: void __thiscall CAGDGatewayInterface::PrintInBoundPacket(void *)
36   23 00001140 private: void __thiscall CAGDGatewayInterface::PrintOutGoingPacket(void *)
37   24 000022F0 private: void __thiscall CAGDGatewayInterface::ProcessPacket(void *)
38   25 00001B20 public: virtual void __thiscall CAGDGatewayCallBack::ReRoute(long,long,long,long,long,long,struct UserDefinedData &,struct AGDGatewayDateTime &)
39   26 00002010 private: enum AGDClientError __thiscall CAGDGatewayInterface::SendNewCallPacket(void *,long)
40   27 00001E50 private: enum AGDClientError __thiscall CAGDGatewayInterface::SendPacket(void *,long)
41   28 00003520 private: bool __thiscall CAGDGatewayInterface::SendTECommand(int,void *,int,int)
42   29 00001990 public: virtual void __thiscall CAGDGatewayCallBack::ServiceStatus(long,long,struct AGDGatewayDateTime &)
43   2A 00001060 public: void __thiscall CAGDGatewayCallBack::SetInterface(void *)
44   2B 000035F0 public: enum AGDClientError __thiscall CAGDGatewayInterface::StartSession(void)
45   2C 00003090 public: enum AGDClientError __thiscall CAGDGatewayInterface::UpdateCallData(long,long,long,struct UserDefinedData &)
46   2D 00001BF0 public: virtual void __thiscall CAGDGatewayCallBack::UpdateCallDataAck(long,long,long,long,struct AGDGatewayDateTime &)
47   2E 00001380 bool __cdecl WinSockInit(void)



Unmanaged C++ DLL Header
C++
/////////////////////////////////////////////////////////////////////////////
//
/*============================= File Header =================================+
 | $Archive: /CCProEngine/VERSION4_2_1/AGDGatewayInterface/AGDGatewayInterface.h $
 | $Revision: 16 $
 | $Date: 11/07/01 2:17p $
 | $Modtime: 11/07/01 2:17p $
 | $Author: Scontractor $
*/
/////////////////////////////////////////////////////////////////////////////
#ifndef _AGDGATEWAYINTERFACE_H_
#define _AGDGATEWAYINTERFACE_H_


/////////////////////////////////////////////////////////////////////////////
// Includes.
/////////////////////////////////////////////////////////////////////////////
#include "AGDGatewaySharedTypes.h"


/////////////////////////////////////////////////////////////////////////////
// Forward Declarations.
/////////////////////////////////////////////////////////////////////////////
class CCProTEAsyncClient;


/////////////////////////////////////////////////////////////////////////////
// Typedefs and Macros. (Where possible)
/////////////////////////////////////////////////////////////////////////////
// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the AGDGATEWAYINTERFACE_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// AGDGATEWAYINTERFACE_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef AGDGATEWAYINTERFACE_EXPORTS
#define AGDGATEWAYINTERFACE_API __declspec(dllexport)
#else
#define AGDGATEWAYINTERFACE_API __declspec(dllimport)
#endif


/////////////////////////////////////////////////////////////////////////////
// Externs and Globals.
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// Enums and Constants.
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// Function Declarations.
/////////////////////////////////////////////////////////////////////////////
void TF_CenterCordAGDGatewayReceive(void *pData);
bool AGDGATEWAYINTERFACE_API WinSockInit();


/////////////////////////////////////////////////////////////////////////////
// Class Declarations.
/////////////////////////////////////////////////////////////////////////////
class AGDGATEWAYINTERFACE_API CAGDGatewayCallBack
{
public:
	CAGDGatewayCallBack(void) {m_zInterface = NULL;}

	// Virtual Callback functions. Must be overridden in derived class.
	virtual void SessionStatus(long iStatus, long iServerId, AGDGatewayDateTime& zDateTime) = 0;
	virtual void LogErrorString(char* szErrStr, long iDebugLevel) = 0;

	// Virtual Callback functions. Need not be overridden in derived class if not needed.
	virtual void ServiceStatus(long iServiceId, long iServiceStatus, AGDGatewayDateTime& zDateTime);
	virtual void NewCallAck(long iRefId, long iStatus, long iSequenceNum, long iCallId, long iServiceId, AGDGatewayDateTime& zDateTime);
	virtual void FoundAgent(long iSequenceNum, long iCallId, long iServiceId, char* szAgentId, AGDGatewayDateTime& zDateTime);
	virtual void CallCleared(long iSequenceNum, long iCallId, long iServiceId, long iStatus, AGDGatewayDateTime& zDateTime);	
	virtual void Disposition(long iSequenceNum, long iCallId, long iServiceId, long iDisposition, UserDefinedData& zCallData, AGDGatewayDateTime& zDateTime);
	virtual void ReRoute(long iSequenceNum, long iNewCallId, long iOldCallId, long iNewServiceId, long iOldServiceId, long iStatus, UserDefinedData& zCallData, AGDGatewayDateTime& zDateTime);
	virtual void UpdateCallDataAck(long iSequenceNum, long iCallId, long iServiceId, long iStatus, AGDGatewayDateTime& zDateTime);
	virtual void MediaListCall(long iSequenceNum, long iCallId, long iServiceId, long iDuration, long iType, long iState, long iAgentId);
	virtual void MediaCallGone(bool bResult, long iCallId);

  // Callback management
  virtual void CallBackUpdateAck(AGDCallbackUpdateType eUpdateType, int iTableId, int iRecordNum, int iServiceId, char* szPhoneNum, char* szAgentId, long iStatus, AGDGatewayDateTime& zDateTime);

private:
	void* m_zInterface;
public:
	void  SetInterface(void* zInterface) { m_zInterface = zInterface; }
	void* GetInterface() { return m_zInterface; }
};

class AGDGATEWAYINTERFACE_API CAGDGatewayInterface 
{
public:
	CAGDGatewayInterface(char *szTenantShortName, CAGDGatewayCallBack* pzCallBack, char* pszPrimaryIpAddress = NULL, int iPrimaryPort = 0, char* pszBackupIpAddress = NULL, int iBackupPort = 0);
	~CAGDGatewayInterface();

	// Commands Sent to the CenterCord.
	AGDClientError StartSession();
	AGDClientError NewCall(long iServiceId, UserDefinedData& zCallData, long iRefId);
	AGDClientError NewCallAgent(long iServiceId, UserDefinedData& zCallData, long iRefId, char *szAgent);
	AGDClientError KillCall(long iSequenceNum, long iCallId, long iServiceId);
	AGDClientError KillAllCallsInService(long iServiceId);
	AGDClientError UpdateCallData(long iSequenceNum, long iCallId, long iServiceId, UserDefinedData& zCallData);
	AGDClientError EndSession();
	AGDClientError DeleteExclusion(long lExclusionType, char* szValue, long lAppId);
	AGDClientError DeleteAllExclusions();
	// StartDate and EndDate should be in Universal format: yyyy-mm-dd hh:mm:ss
	AGDClientError InsertExclusion(long lExclusionType, char* szValue, long lAppId, char* szStartDate, char* szEndDate);
	AGDClientError InsertExclusionWithoutNotify(long lExclusionType, char* szValue, long lAppId, char* szStartDate, char* szEndDate);	
	AGDClientError NotifyCCOfExclusionInsert();
	AGDClientError GetMediaList( long iServiceId, long iDurationMin);
	AGDClientError KillMediaCall( long iCallId);
    // Callback management
    AGDClientError CallBackUpdate(AGDCallbackUpdateType eUpdateType, int iTableId, int iRecordNum, int iServiceId, char* szPhoneNum, char* szAgentId = NULL);
	

public:
	CAGDGatewayCallBack*	m_pzCallBack;

private:
	long  m_zSocket;
	long  m_iServerId;

	AGDClientError SendPacket(void* pzPacket, long iPacketSize);
	AGDClientError SendNewCallPacket(void* pzPacket, long iPacketSize);
	void ProcessPacket(void* pzInPacket);
	void PrintOutGoingPacket(void* pzOutPacket);
	void PrintInBoundPacket(void* pzOutPacket);
	bool LoginToCC(char* szCCIPAddress, int port);	
	void Disconnect();
	friend void TF_CenterCordAGDGatewayReceive(void *pData);
public:
	void ExecuteCCDown();
	void ExecuteCCTimeOut();
	void ExecuteCCUp();

	// TE Client Interfaces. NEED TO CHANGE CLIENTTYPE TO CT_AGDGATEWAYINTERFACE
	CCProTEAsyncClient*				m_pzCCProTEAsyncClient;

private:
	bool		SendTECommand(int iTransactionId, void* pData, int iSizeOfData, const int siTimeOutInMSecs=300);
	void*		m_pRecordSet;
	bool		DeleteRecordSet();
};

#endif


Included Files: AGDGatewaySharedTypes.h
C++
#ifndef __AGDGATEWAYSHAREDTYPES_H_
#define __AGDGATEWAYSHAREDTYPES_H_
#include "CCProCallData.h"


// Character string sizes.
const long	CCPRO_AGD_AGENT_ID_LENGTH			= 32;
const long	CCPRO_AGD_IP_ADDRESS_LENGTH		= 32;
const long  CCPRO_AGD_DATE_TIME_LENGTH  = 32;  
const long	CCPRO_AGD_FILENAME_LENGTH   = 80;
const long	CCPRO_AGD_ERROR_LENGTH      = 80;

// Service Status
enum AGDServiceStatus
{
	AGD_SVC_STATUS_NONE				= 0,
	AGD_SVC_STATUS_INACTIVE		= 1,
	AGD_SVC_STATUS_ACTIVE			= 2,
	AGD_SVC_STATUS_UNMANNED		= 3,
	AGD_SVC_STATUS_HOLIDAY		= 4,
	AGD_SVC_STATUS_PAUSE			= 5,
	AGD_SVC_STATUS_FAILED			= 6,
	AGD_SVC_STATUS_WAIT				= 7,
	AGD_SVC_STATUS_ACTIVATING	= 10,
};

// Debug levels
enum AGDLogDebugLevels
{
	iAGDDbgLevelNone			= 0,
	iAGDDbgLevelErrors		= 1,
	iAGDDbgLevelWarnings	= 2,
	iAGDDbgLevelTrace			= 3,
	iAGDDbgLevelAll				= 9,
};

// Errors returned directly by interface.
enum AGDClientError
{
	AGDErrorNone = 0,
	AGDErrorNotConnected,
	AGDErrorAlreadyConnected,
	AGDErrorTooManyCalls,
	AGDErrorSocketError,
	AGDErrorException,
	AGDErrorTEClient,
};

// Status's returned from the Centercord.
enum AGDCCStatus
{
	AGDStatusOk = 0,                    // 0

	AGDStatusUnknown,                   // 1

	// SessionStatus
	AGDStatusConnected,                 // 2
	AGDStatusDisconnected,              // 3
	AGDStatusCCDown,                    // 4
	AGDStatusCCTimeOut,                 // 5
	AGDStatusCCUp,                      // 6

	// NewCallAck
	AGDStatusNewCall,                   // 7
	AGDStatusTooManyCalls,              // 8
	AGDStatusInvalidServiceId,          // 9

	// CallCleared
	AGDStatusAgentHungUp,               // 10
	AGDStatusAgentLoggedOut,            // 11
	AGDStatusCallKilled,                // 12
	AGDStatusInternalError,             // 13
	AGDStatusInactiveReRouteFailed,     // 14
	AGDStatusUnmannedReRouteFailed,     // 15
	AGDStatusQMaxTimeReRouteFailed,     // 16
	AGDStatusQMaxLenReRouteFailed,      // 17
	AGDStatusHolidayReRouteFailed,      // 18
	AGDStatusIVRCallEnded,	            // 19
	
	// ReRoute
	AGDStatusInactiveReRouted,          // 19
	AGDStatusUnmannedReRouted,          // 20
	AGDStatusQMaxTimeReRouted,          // 21
	AGDStatusQMaxLenReRouted,           // 23
	AGDStatusHolidayReRouted,           // 24

	// Xfer Status
	AGDStatusAgentTransferred,          // 25
	AGDStatusAgentTransferFailed,       // 26
	AGDStatusIVRTransferred,            // 27
	AGDStatusIVRTransferFailed,         // 28

	// UpdateCallDataAck
	AGDStatusUpdateCallDataSucceeded,   // 29
	AGDStatusUpdateCallDataFailed,      // 30

	// CallbackUpdate --- CQ 166316
	AGDStatusCallbackUpdateSucceeded,   // 31           // CQ 166316                               
	AGDStatusCallbackUpdateFailed,      // 32           // CQ 166316
};

enum AGDCallbackUpdateType    // CQ 166316
{
	AGD_CALLBACK_ADD		= 1,
	AGD_CALLBACK_UPDATE		= 2,
	AGD_CALLBACK_DELETE		= 3
};




/////////////////////////////////////////////////////////////////////////////
// Function Declarations.
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// Class Declarations.
/////////////////////////////////////////////////////////////////////////////

// Note that this is the SYSTEMTIME struct.
struct AGDGatewayDateTime
{
    unsigned short wYear;
    unsigned short wMonth;
    unsigned short wDayOfWeek;
    unsigned short wDay;
    unsigned short wHour;
    unsigned short wMinute;
    unsigned short wSecond;
    unsigned short wMilliseconds;
};



#endif


Included Files: ccprocalldata.h
C++
#ifndef __CCPRO_CALLDATA_H
#define __CCPRO_CALLDATA_H

/* FIX */
// do not like this redefinition here
#ifndef MAX_SIP_ADDRESS_SIZE
	#define MAX_SIP_ADDRESS_SIZE 255
#endif

enum AgentAssistType
{
	NLPAssistance         = 0,
	AgentAssistance       = 1,
	NLPAndAgentAssistance = 2
};
const int EMAIL_MAILBOX_SIZE =	256;

const int PHONE_NUMBER_STRING_SIZE				= 25;
const int FIRST_NAME_STRING_SIZE				  = 51;
const int LAST_NAME_STRING_SIZE				    = 21;
const int CALLBACK_MEMO_STRING_SIZE			  = 256;
const int USER_DEFINED_DATA_SIZE		      = 78;
const int ANI_STRING_SIZE									= 32;
const int DNIS_STRING_SIZE		            = 32;
const int CALLER_ID_STRING_SIZE		        = 48;
const int DISP_CODE_STRING_SIZE		        = 25;
const int MAX_USER_DEFINED_FIELDS           = 20;
const int TABLE_NAME_STRING_SIZE				  = 64;


// Screen Pop Data
typedef struct ScreenPopData
{
	//AODPhoneNumbers	phoneNums;

	char		szPhoneNumber[PHONE_NUMBER_STRING_SIZE];
	char		szFirstName[FIRST_NAME_STRING_SIZE];
	char		szLastName[LAST_NAME_STRING_SIZE];
	char		szDnis[DNIS_STRING_SIZE];
	char		szANI[ANI_STRING_SIZE];
//	char		szDnis[MAX_SIP_ADDRESS_SIZE+1];
//	char		szANI[MAX_SIP_ADDRESS_SIZE+1];
	char		szCallerID[CALLER_ID_STRING_SIZE];

} ScreenPopData;

// User Defined Data
typedef struct
{
	// User Controlled Call Data (Application data)
	char		szUserDefined1[USER_DEFINED_DATA_SIZE];
	char		szUserDefined2[USER_DEFINED_DATA_SIZE];
	char		szUserDefined3[USER_DEFINED_DATA_SIZE];
	char		szUserDefined4[USER_DEFINED_DATA_SIZE];
	char		szUserDefined5[USER_DEFINED_DATA_SIZE];
	char		szUserDefined6[USER_DEFINED_DATA_SIZE];
	char		szUserDefined7[USER_DEFINED_DATA_SIZE];
	char		szUserDefined8[USER_DEFINED_DATA_SIZE];
	char		szUserDefined9[USER_DEFINED_DATA_SIZE];
	char		szUserDefined10[USER_DEFINED_DATA_SIZE];
	char		szUserDefined11[USER_DEFINED_DATA_SIZE];
	char		szUserDefined12[USER_DEFINED_DATA_SIZE];
	char		szUserDefined13[USER_DEFINED_DATA_SIZE];
	char		szUserDefined14[USER_DEFINED_DATA_SIZE];
	char		szUserDefined15[USER_DEFINED_DATA_SIZE];
	char		szUserDefined16[USER_DEFINED_DATA_SIZE];
	char		szUserDefined17[USER_DEFINED_DATA_SIZE];
	char		szUserDefined18[USER_DEFINED_DATA_SIZE];
	char		szUserDefined19[USER_DEFINED_DATA_SIZE];
	char		szUserDefined20[USER_DEFINED_DATA_SIZE];
} UserDefinedData;

typedef struct DCallData
{
	int				iEventCode;
	int			siCallID;
	int				siServiceID;
	int				siOriginalServiceID;

	// identifies call type and category
	int				iCallCategory;			
	int				iCallType;

	// Callback info
	int			siDialModeCode;
	int			siCallBackFlag;
	char			szCallbackMemo[CALLBACK_MEMO_STRING_SIZE];

	// CCPro Controlled Data( Screen POP Data)
	ScreenPopData	screenData;

	// User Defined Data
	UserDefinedData	userData;

	int			siMailQueId;
	int				iMessageId;
	char			szForwardToMBox[EMAIL_MAILBOX_SIZE];

	char			szTableName[TABLE_NAME_STRING_SIZE];
	int				iCallTableRecordNum;
	int				iStoreManagerId;
	int				iTargetManagerId;

} DCallData ;


#endif


What I have tried:

Writing a C++/CLR wrapper
Changing the DllImport CallingConvention
Several variations on pushing the strings through such as marshal.
Posted
Updated 9-Jun-16 0:40am
v3

1 solution

Your are working in the wrong direction. The declaration is straitforward and not with "decorared names" and even so the data type declaration.

My tip is to write a C++ wrapper dll which calls the other dll. So you can separate the problems from marshalling and calling the dll.

But somebody else got already an answer to this question.
   
Comments
Dev O'Connor 9-Jun-16 6:43am
   
I have tried without the decorated names but only works with decorated calls but then i get the AccessViolation.

I have tried writing a wrapper for this DLL several times but C++ i do not know, i dont know the syntax, structure or how it is laid out. i dont know how to reference the class object or instantiate them (never used C++ before)

THis is why i tried with the marshalling but that doesnt work. do you know any services that i could supply this information to that could write it for me (even if its paid for) becuase ive spent over a week on this already and getting nowhere fast.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900