views:

12

answers:

1

Hi @ all,

I am a little stuck with a strange Problem. I need to control some Hardware via a 3rd Party Active-X typelibrary. My program is written in C#. The Problem is one API / COM call needs a ref to a PVariant - So if I get it correctly a Pointer to a Variant. To make things worse, this is just the first address of an Varaint Array with not fixed size (element count).

Problem is - beside this beeing not the best practice - I got no chance of changing that method and no way to working around it.

Anybody ever needed to create a COM compatible Variant-array and pass it's start address to a COM method? How is that done?

I'd appreciate any help on this!

Thx in advanced

Corelgott

A: 

Have you tried using System.Runtime.InteropServices.Marshal.GetNativeVariantForObject?

Also, now that I jogged my memory, a Variant Array (VT_ARRAY) is really a SAFEARRAY by another name. You could try passing in an Object[] to see if .Net's default marshalling will handle it.

codekaizen