Solved

COM Interface - multiple parameters

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Handle Exceptions during instantiation 28 428
mixing C++ & C# in Vis Studio 2013 7 235
typedef std::deque<BYTE> ByteVector is broken in vs2012 23 89
Socket Programming (Unix) 8 153
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

761 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