dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Interoperability issue between VC++ (ocx) & VB.NET applications

  1. #1
    Join Date
    Jan 2016
    Posts
    1

    Interoperability issue between VC++ (ocx) & VB.NET applications

    Hello,

    We are migrating a product from VB6 to VB.NET and facing an issue.
    This product interacts with a function defined in VC++ component (.ocx).

    1. VB6 & VB.NET function call:

    result = TestFunc(Param1, Param2, Param3)

    2. VC++:
    a) Function definition in .CPP file:
    long TestFunc(long FAR* Param1, const VARIANT FAR& Param2, long Param3)
    {
    ...
    }

    b) Function signature in .ODL file:
    long TestFunc(long* Param1, VARIANT Param2, long Param3);

    c) Function signature in .h(header) file:
    afx_msg long TestFunc(long FAR* Param1, const VARIANT FAR& Param2, long Param3);


    "Param2" in above "TestFunc" is defined as byte array in VB6 & VB.NET.

    In VC++, the corresponding type for "Param2" in "TestFunc" is - "const VARIANT FAR& Param2".

    In VB6, the byte array values passed gets modified in VC++ "TestFunc" & the modified values are received in VB6 "Param2" variable.

    Issue in VB.NET:

    In VB.NET, the byte array values passed gets modified in VC++ "TestFunc".
    However, the modified values are not transferred from VC++ to VB.NET. The "Param2" variable still has the original values & not the modified values.

    Could you please provide us information on how to obtain the modified byte array values in VB.NET from the Variant variable in VC++ component?

    Thanks in advance.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,592

    Re: Interoperability issue between VC++ (ocx) & VB.NET applications

    The const qualifier in
    Code:
    long TestFunc(long FAR* Param1, const VARIANT FAR& Param2, long Param3)
    must be removed to allow this function to modify the Param2.
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Interoperability issue between VC++ (ocx) & VB.NET applications

    Good point, Victor, however, if that was the problem, wouldn't then the C++ compiler flag attempts to modify the passed byte array as an error in the first place? Wouldn't const, as it's used here, just make the VARIANT structure itself constant, but not the actual array it refers to? (I'm not completely sure about the latter, though, as I'm currently not aware of the details concerning the VARIANT structure at the time.)

    Besides, to me this looks more like a VB .NET question, or perhaps native C++, rather than C++/CLI, so maybe the thread should be moved to the appropriate forum section?
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,592

    Re: Interoperability issue between VC++ (ocx) & VB.NET applications

    Quote Originally Posted by Eri523 View Post
    Besides, to me this looks more like a VB .NET question, or perhaps native C++, rather than C++/CLI, so maybe the thread should be moved to the appropriate forum section?
    Agree. So move it to VC++ forum
    Victor Nijegorodov

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)