interop: Passing pointer to COM to efficiently receive large data chunk

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I'm writing COM to expose some unmanaged imagery generation functions to c#.
My question is how to best (easiest, clearest coding style) pass a managed
pointer to COM to receive back a loaded image:

example 1: using safearray
COM:
process([in,out] SAFEARRAY* bytes)
C# call:
byte[] bytes = byte[256];
process(bytes);

Question: does this pass a pointer, or is it marshalled (i.e inefficient)?


example 2: using fixed array size
COM:
process([in,out] byte[256] bytes]

Disadvantage: fixed size must be specified up front -- or is it safe to
write past the apparently "fixed" array size internal to the com function if
the true size of array is also passed as a parameter? (i.e in the case that
image size should vary fro 256?)


What it the current wisdom of how to do this best?


thanks in advance.

-Robert


.



Relevant Pages

  • Re: SafeArrays problem between Fortran and VB .Net
    ... | End Interface ... By declaring that intData is an Integer, POINTER:: you tell the ... compiler to pass a SAFEARRAY**, ... | a method expecting an array of rank 1." ...
    (comp.lang.fortran)
  • Re: Remove First Row from Variant Array FAST?
    ... >it thinks there is 1 fewer element in the array and incrementing the ... Unlikely you could manipulate the SAFEARRAY construct as you'd like. ... part of the SAFEARRAY structure is the pointer to the data, ... your system with memory leaks by manipulating the pointer directly. ...
    (microsoft.public.excel.programming)
  • Re: Remove First Row from Variant Array FAST?
    ... When I say manipulating the SAFEARRAY so that ... it thinks there is 1 fewer element in the array and incrementing the ... pointer to the first item, if this is possible, I expect it to take ...
    (microsoft.public.excel.programming)
  • Re: char **argv & char *argv[]
    ... "pointer to pointer to char". ... >> pointer)) pointing to the first element of an array. ... so we have to start adding more context. ... type "pointer to char", rather than "array MISSING_SIZE of char". ...
    (comp.lang.c)
  • Re: why cannot assign to function call
    ... hypothetical C-like languages, ... sizeof business would still indicate that a pointer was being passed. ... talk about variables of an array type. ... the earlier version of the standard didn't have numbered ...
    (comp.lang.python)