Solved

COM Interface - multiple parameters

Posted on 2006-10-19
5
322 Views
Last Modified: 2010-04-01
Hi,
I am working on a C++ COM interface that gets used by different programs built on VB 6, PowerBuilder, Visual pro.
There a couple of functios that have several parameters & I want to combine all those parameters in to 1 or just a couple of parameters. I was thinking an array or a few parameter arrays.
The parameters are of different types like  long, VARIANT_BOOL , BSTR , double

Does anyone have a suggestion of a good approach for this?  Maybe an example.

Thanks a lot.
0
Comment
Question by:chicho12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
mrblue earned 400 total points
ID: 17774929
You can use VARIANT type to pass more than one value (when you want to comply to Automation)
or you can use structs (non-Automation version).
The first case is more general because it enabled you to call methods from script languages also.
The later is more flexible - you can use C-like structure types.

For example in .idl file you can declare:

typedef [helpstring("TestStructType")]
struct tagREMILLUMINATOR_CAPS {
      short sVal1;
      long nVal2;
      VARIANT vVal3;
      FLOAT fltVal4;
} TestStructType;

// ...

[
      object,
      uuid(CD3A1A1B-0E68-4bbc-83D9-E9D554A75566),
      helpstring("ITestInterface Interface"),
      pointer_default(unique)
]
interface ITestInterface : IUnknown
{
      [helpstring("method GetComplexVal")] HRESULT GetComplexVal([out] TestStructType *ComplexVal);
0
 
LVL 8

Expert Comment

by:mrblue
ID: 17774938
You can also add:

struct TestStructType;

to library block if you want you type to be available through type library
0
 

Author Comment

by:chicho12
ID: 17777719
In my case the function will be receiving the values [in].  Will I be able to use the same idea?

Thanks,
0
 

Author Comment

by:chicho12
ID: 18000772
sorry,
I was assigned to another project. I haven't been able to work on this.
i will give the points to mrblue.

thanks,
Chicho
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question