0

I'm trying to create a window using OpenCV with VB6.

The original C++ code is this:

C: IplImage* cvCreateImage(CvSize size, int depth, int channels)

So in VB6 I declare the following function:

Private Declare Function cvCreateImage CDecl Lib "opencv_core220.dll" (ByRef uSize As CvSize, ByVal uDepth As Long, ByVal uChannels As Long) As Long

Private Type CvSize
    width As Long
    height As Long
End Type

And then I call like this:

Dim nSize As CvSize
nSize.width = 1024
nSize.height = 768

Dim l8 As Long
Dim l3 As Long
l8 = 8
l3 = 3

Dim lDisplayImage As Long
lDisplayImage = cvCreateImage(nSize, l8, l3)

Looks perfectly fine to me, but VB6 tells me:

Wrong DLL calling convention.

What am I doing wrong here?

Thank you!

Étienne Laneville
  • 4,697
  • 5
  • 13
  • 29
tmighty
  • 10,734
  • 21
  • 104
  • 218
  • VB6 is from, what?, 1998? Why are you still using such an outdated language? – Jesper Juhl Oct 12 '19 at 15:40
  • @JesperJuhl I have a really big monster. I'm converting it since 6 years, but still not finished, so I'm still stuck with VB6. – tmighty Oct 12 '19 at 15:54
  • 1
    @tmighty -- By default, the calling convention for C++ is `_cdecl`. I have not used VB6 in years, but I believe the calling convention is `_stdcall`. Google what calling conventions are, as that is a big topic -- in a nutshell it determines how parameters are passed to the function and how the `return` from such functions are handled. If the calling conventions do not match between the caller and the callee, you will get errors like this. – PaulMcKenzie Oct 12 '19 at 17:06

0 Answers0