How is the VT field set when a Variant is passed from VB6 to VC++?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How is the VT field set when a Variant is passed from VB6 to VC++?

  1. #1
    Join Date
    Feb 2013
    Posts
    1

    How is the VT field set when a Variant is passed from VB6 to VC++?

    I have been puzzled by the problem for days now, and any help is sincerely appreciated.
    I use VB6 to control an imaging board to grab images from a CCD camera. I then pass the pixel data, which is in the form of a 2D Integer array, to a C++ function to do some processing (centroiding). The function resides in a dll named 'mathLib'.

    The signature of the C++ function is:
    STDMETHODIMP Cmath::centroid(VARIANT *image, short width, short height, VARIANT *theCentroid) ;

    The context in VB6 is as follows:
    'Image' is an activeX object embodying the image grabbed from the imaging board. Image.getImageData returns a 2D Integer array containing the pixel values of the image

    To call the C function, I do:
    dim centroid as variant
    dim imageArray as variant
    ...
    let width = Image.getImageWidth
    let height = Image.getImageHeight
    let imageArray = Image.getImageData 'get the pixel value array
    Let centroid = mathLib.centroid(imageArray, width, height) 'call the C++ function
    ...

    I tried 2 imaging boards from 2 different companies. The pixel data array in VB6 look the same - both are 2D Integer arrays of size 1024x1024. However when the array is passed to the C++ routine, there is a 5 times difference in processing speed. I examined the array on the C++ side, and noticed that the VT field has different values. One is 0x6002 (i.e. VT_BYREF & VT_ARRAY & VT_I2) and the other is 0x2002 (i.e. VT_ARRAY & VT_I2). I believe this is where the problem originates.

    Can someone tell me how this comes to be? Where and how is the VT field of the 'imageArray' set when it's passed from VB6 to VC++? Notice that there is no extra processing in my code between getting the imageArray and calling the C++ function.

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,959

    Re: How is the VT field set when a Variant is passed from VB6 to VC++?

    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center