Solved

COM Interface - multiple parameters

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

776 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