title: Wrong DLL calling convention using VB6
body: <p>I'm trying to create a window using OpenCV with VB6.</p>
  
  <p>The <a href="https://docs.opencv.org/2.4/modules/core/doc/old_basic_structures.html" rel="nofollow noreferrer">original C++ code</a> is this:</p>
  
  <pre><code>C: IplImage* cvCreateImage(CvSize size, int depth, int channels)
  </code></pre>
  
  <p>So in VB6 I declare the following function:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>And then I call like this:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Looks perfectly fine to me, but VB6 tells me:</p>
  
  <blockquote>
    <p>Wrong DLL calling convention.</p>
  </blockquote>
  
  <p>What am I doing wrong here?</p>
  
  <p>Thank you!</p>