COM Interop and Pointer to Array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    COM Interop and Pointer to Array

    A function in a COM DLL I use takes a pointer to the first element in
    an array of short integers.

    Foo(short* array)

    COM interop provides this function to me in the .NET world by making
    the parameter “ref short”.

    Foo(ref short array)

    It seems like no matter what I try, the COM DLL only sees the first
    element in the array. Is there a way to get it to see the entire array
    of values? Maybe some sort of marshalling I haven’t tried yet?

    Thanks,
    Mike
  • PvdG42

    #2
    Re: COM Interop and Pointer to Array

    "Mike" <MLM450@hotmail .comwrote in message
    news:f71ac631-5d1c-449e-8db5-7154e5c5c4e9@u5 7g2000hsf.googl egroups.com...
    A function in a COM DLL I use takes a pointer to the first element in
    an array of short integers.

    Foo(short* array)

    COM interop provides this function to me in the .NET world by making
    the parameter “ref short”.

    Foo(ref short array)

    It seems like no matter what I try, the COM DLL only sees the first
    element in the array. Is there a way to get it to see the entire array
    of values? Maybe some sort of marshalling I haven’t tried yet?

    Thanks,
    Mike


    Assuming you are using C#, what happens happens if you change the parameter
    type to Foo(ref short[] array)?

    Comment

    Working...