Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ and COM -- parameters -- multiple results

Status
Not open for further replies.

hsandwick

Programmer
Sep 10, 2001
286
US
Hello:

C++/COM environment -- able to return one result from parameter; what's the secret to returning multiple results, please?

Thanks!

Helen
 
Does this work if there are multiple data types, or only when calling a pointer to an array of one data type?

Cheers. H
 
If you're actually using COM and programming interfaces, this is a sample of what it could look like within the .idl file:

[helpstring("method GetValue")] HRESULT GetValue([in] int iIndex, [in, out] LPSTR* psValueA, [in, out] LPSTR* psValueB);

Here we're calling GetValue(), passing "in" (only) the index, passing "in" two char pointers and receiving those same two char pointer variables "out". COM requires you to create and pass "in" the addresses of those two string pointer variables, so it can fill those variables and pass them back "out". That's why they are defined as [in, out] variables.

So, when you first set up the variables, make sure to define them as [in, out] if you want to return one or more character strings from a COM object.

Does this help you understand?

BTW:
This example assumes that the project is a C++ client calling a C++ COM object. Otherwise, you'll likely have to use BSTR and/or SAFEARRAY variables to communicate between VB and C++.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top