tags:

views:

40

answers:

1

I have a C Library Cdll.dll which has the function

int _stdcall AddVersion(int repval) 
{
    return (repval + 10);
}

I am calling this AddVersion function from a VB dll.

Private Declare Function AddVersion Lib "cdll.dll" (ByVal Repval As Integer) As Integer
...

Public Function VbMessageHandler(ByRef intVal As Integer) As Integer
   intVal = AddVersion(10)
End Function

I am calling this VB dll from a C dll by creating a COM wrapper for the VB dll.

ret = ObjVbclass->VbMessageHandler(&IntegerValue);

when I use this VBWrapper dll in my C exe application, it crashes by throwing Runtime exception.

+3  A: 

Your declaration is wrong. A VB6 Integer is 16-bits for historical reasons, a C int is 32-bits. Use Long instead.

Private Declare Function AddVersion Lib "cdll.dll" (ByVal Repval As Long) As Long
Hans Passant
Using Long also didn't avoid the crash. Any other suggestions?
Karthick
You'll need to describe "crash".
Hans Passant
The VBwrapperdll(C dll) is executed from a thread in a C application. The thread exits with an exception (observed while debugging the app). No output is received. Error handler is directly called in the VB application.
Karthick