PDA

Click to See Complete Forum and Search --> : Problem while Accessing a C++ DLL


translogic
Jul 28th, 2000, 02:37 AM
Hi,


In one of my project I am trying to access a function inside a DLL(I think
the DLL is written in C++). I am not getting any error if I access a function
that is not having any parameter. But I am getting an error(Runtime Error:49,
Bad DLL Calling Convention) if a function requires any parameter(s).

The function is declared in C++ as:

int QSOpenQueue
(
const char * pHostName,
const char * pQSMgrName,
const char * pQueueName,
int Version,
int IO Type,
int * pPortID
);

In the above function, first 5 parameters are input, the last parameter is
an output. Ie. When we call this function, the function assigns a
value for "pPortID"(Last Parameter).

The above function is converted to:

Private Declare Function QSOpenQueue Lib "QSAPI12.dll" (ByVal HostName As String, ByVal QSMgrName As String, ByVal QueueName As String, ByVal Version As Long, ByVal IOType As Long, PortID As Long) As Long

This is the code I am using to call the function(QSOpenQueue)

Dim rtnValue As Long
Dim lngPortID As Long

Dim strHostName As String
Dim strQMgrName As String
Dim strQueueName As String
Dim lngVer As Long
Dim lngIOType As Long

strHostName = txtHostName
strQMgrName = txtServiceName
strQueueName = txtQueueName
lngVer = Val(txtVersion)
lngIOType = 5

rtnValue = QSOpenQueue(strHostName, strQMgrName, strQueueName, lngVer, lngIOType, lngPortID)

MsgBox rtnValue, vbInformation


I get an error(Runtime Error:49, Bad DLL Calling Convention) in the line:

rtnValue = QSOpenQueue(....

It looks like when the function sets the value to "lngPortID"(Last Parameter)
the system blows.

What should be the VB datatype for "int * pPortID"?

Please help me.

Thanks

Paul.