Solved

COM Interface - multiple parameters

Posted on 2006-10-19
5
300 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now