Home > Software engineering >  Consult, MFC development COM function how to return to complex data types (such as custom class, str
Consult, MFC development COM function how to return to complex data types (such as custom class, str

Time:09-25

Recently in learning COM development, want to consult the function in the COM class can return a custom type?
If you can, please give directions under the train of thought or give a simple example, be obliged! I am MFC development COM class, using c # project,

CodePudding user response:

The variant type

CodePudding user response:

@ jacksonfan can use method under the detailed said?

CodePudding user response:

It is best to use a custom data interface, don't use UDT,
Such data can be automatically parsing in c #,

CodePudding user response:

If you want to return the custom types, you might as well within their implement an interface, and then use QueryInterface to query, get the interface pointer, and then through the different ways to get access to this interface provides several custom data, of course, you can also define structure, as a method of parameter directly, because the COM interface, except AddRef all specification for HRESULT return value types, so only through the way of parameter passing Pointers to implement,

CodePudding user response:

Don't understand the com, if you need to call com interfaces can't return the type of their packaging a function, function call com interface, and the return value of the com interface package according to the format you need, then put this function for people to use directly

CodePudding user response:

Yes, but you must encapsulate the data as variant_t type