I am looking at an example project from sourceforge for communication with the TSAPI (not TAPI) telephone system - http://tsapi.sourceforge.net/ .
My development environment is 32-bit Windows XP, and the x86 target is set for the project.
This works fine, as provided for working with .Net 2, but I need to run it against .Net 4. When I change the structure and run the 1st function, it returns -1, indicating a failure.
Function Definition:
[DllImport("csta32.dll")]
public static extern int acsOpenStream(ref UInt32 acsHandle, int invokeIDType, UInt32 invokeID, int streamType, char[] serverID, char[] loginID, char[] passwd, char[] applicationName, int acsLevelReq, char[] apiVer, ushort sendQSize, ushort sendExtraBufs, ushort recvQSize, ushort recvExtraBufs, ref PrivateData_t priv);
C # code (extracted from a sample project) to call this function:
public bool open(string strLoginId, string strPasswd, string strServerId)
{
char[] serverId = strServerId.ToCharArray();
char[] loginId = strLoginId.ToCharArray();
char[] passwd = strPasswd.ToCharArray();
int invokeIdType = 1;
UInt32 invokeId = 0;
int streamType = 1;
char[] appName = "Mojo".ToCharArray();
int acsLevelReq = 1;
char[] apiVer = "TS1-2".ToCharArray();
ushort sendQSize = 0;
ushort sendExtraBufs = 0;
ushort recvQSize = 0;
ushort recvExtraBufs = 0;
Csta.PrivateData_t privData = new Csta.PrivateData_t();
privData.vendor = "MERLIN ".ToCharArray();
privData.length = 4;
privData.data = "N".ToCharArray();
ushort numEvents = 0;
Csta.EventBuf_t eventBuf = new Csta.EventBuf_t();
ushort eventBufSize = (ushort)Csta.CSTA_MAX_HEAP;
try
{
int openStream = Csta.acsOpenStream(ref acsHandle, invokeIdType, invokeId, streamType, serverId, loginId, passwd, appName, acsLevelReq, apiVer, sendQSize, sendExtraBufs, recvQSize, recvExtraBufs, ref privData);
An C ++ example application is also proposed, in which a function call:
m_nRetCode = acsOpenStream(&m_lAcsHandle
, APP_GEN_ID
, (InvokeID_t)m_ulInvokeID
, ST_CSTA
, (ServerID_t *)(serverID)
, (LoginID_t *)(loginID)
, (Passwd_t *)(password)
, (AppName_t *)"TSAPI_AgentView"
, ACS_LEVEL1
, (Version_t *) "TS1-2"
, 10
, 5
, 50
, 5
, (PrivateData_t *)&m_stPrivateData);
If I changed DLLImport to
[DllImport("csta32.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int acsOpenStream(ref UInt32 acsHandle, int invokeIDType, UInt32 invokeID, int streamType, char[] serverID, char[] loginID, char[] passwd, char[] applicationName, int acsLevelReq, char[] apiVer, ushort sendQSize, ushort sendExtraBufs, ushort recvQSize, ushort recvExtraBufs, ref PrivateData_t priv);
I get a runtime error
PInvokeStackImbalance
: PInvoke "Mojo! Csta:: acsOpenStream" . , , PInvoke . , PInvoke .
Avaya - , :
RetCode_t acsOpenStream(
ACSHandle_t *acsHandle,
InvokeIDType_t invokeIDType,
InvokeID_t invokeID,
StreamType_t streamType,
ServerID_t *serverID,
LoginID_t *loginID,
Passwd_t *passwd,
AppName_t *applicationName,
Level_t acsLevelReq
Version_t *apiVer,
unsigned short sendQSize,
unsigned short sendExtraBufs,
unsigned short recvQSize,
unsigned short recvExtraBufs
PrivateData_t *privateData);