Print Page | Close Window

Returning an array of objects from C# to COM/C++?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: General Discussion
Forum Description: Topics Related to Visual C++ MFC Development in General
URL: http://forum.codejock.com/forum_posts.asp?TID=16612
Printed Date: 29 April 2024 at 5:27am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Returning an array of objects from C# to COM/C++?
Posted By: znakeeye
Subject: Returning an array of objects from C# to COM/C++?
Date Posted: 19 April 2010 at 11:38am
I have written a COM component in C#. One of the interfaces contains a function that must return a list of objects of another exported interface:
 
[DispId(1)]
void GetList(ref MyClass[] list);
 
This is no rocket science as long as we stay in the world of .NET, but in MFC we find ourselves in hell:
 
void GetList(SAFEARRAY * * list)
{
    static BYTE parms[] = VTS_UNKNOWN;
    InvokeHelper(0x1, DISPATCH_METHOD, VT_EMPTY, NULL, parms, test);
}
 
 
Q1: Is this the preferred way of returning an array of objects from a COM object?
 
Q2: How do I instansiate the MyClass objects on the C++ side?


-------------
PokerMemento - http://www.pokermemento.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net