• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

COM Interface - multiple parameters

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
chicho12
Asked:
chicho12
  • 2
  • 2
1 Solution
 
Dariusz DziaraProgrammerCommented:
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
 
Dariusz DziaraProgrammerCommented:
You can also add:

struct TestStructType;

to library block if you want you type to be available through type library
0
 
chicho12Author Commented:
In my case the function will be receiving the values [in].  Will I be able to use the same idea?

Thanks,
0
 
chicho12Author Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now