Re: CCW COM and Parameters

Giganews Newsgroups
Subject: Re: CCW COM and Parameters
Posted by:  Pavel Minaev (int1…
Date: Sun, 26 Apr 2009

On Apr 25, 6:18 pm, James <baodurasp.…@community.nospam> wrote:
> I am writing a component in C# which is a COM Callable Wrapper.  Some of the
> methods pass structs across COM.  My question is, how does COM pass
> parameters such as structs?

It's up to you, depending on how you define the interface.

>  I know that C# passes structs by value.  The
> struct data being passed from the Win32 client is never going to be modified,
> so I would like to prevent making a copy of the struct across the COM
> barrier.  In C# The struct is being passed by reference (added ref keyword to
> parameter) since I don't want to make a copy there either.  I'm going through
> enough layers already and I would prefer not to be making multiple copies of
> a struct every time it is passed as a parameter.

If your C# code defines the argument as "ref" or "out", there should
be no copy involved during marshaling, unless the struct itself has
some fields that require special marshaling (e.g. strings, or arrays
declared without "fixed" keyword).



In response to

CCW COM and Parameters posted by James on Sat, 25 Apr 2009