Link to home
Start Free TrialLog in
Avatar of yonit
yonit

asked on

Passing structure in COM

Hi,
Can I transfer my defined structure or a pointer to my structure as a COM paramter. I think that the user can recognize it from idl.
Thanks !
Avatar of Chase707
Chase707

yes,

in the idl file:

typedef struct MY_STRUCT
{
    int mystuff;
} MY_STRUCT;
...
interface IMyInterface : IUknown
{
   HRESULT myMethod( [in] MY_STRUCT* pStruct);
}
...

then just implement it in your component as normal.

Chase707
ASKER CERTIFIED SOLUTION
Avatar of vcppmfc
vcppmfc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yonit

ASKER

What can be done for VB?
In VB you can just define the structure using VB conventions before you call the method.  I do not know the VB language well, so I do not recall the exact syntax.

I think it's something like:
...
Type MY_STRUCT
   stuff as int
End Type
...

As long as your struct contains only Automation compatible types  (those defined in the VARIANT enum), then IDL will handle the details of marshalling your structures across processes.

Avatar of yonit

ASKER

Sorry. I ment to give the points to Chase707. Can it be changed ???
I'm not sure about changing it, but you can create another question called 'points for Chase707'.  Then when I post an answer, you can then accept it.  It will end up costing you 50 more points though.

Chase707
Avatar of yonit

ASKER

I will