LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing an array as a pointer from LV to COM

I wrote a small test COM dll to try different ways of passing an array between LV and COM.  The three ways I tried are:

1.  Variant of type SAFEARRAY
2.  SAFEARRAY
3.  Pointer to first element of array with a size_is specifier

__interface IArrayFunctions : IDispatch
{
    [id(1), helpstring("method GetArray1")] HRESULT GetArray1([out] VARIANT* Arr);
    [id(2), helpstring("method GetArray2")] HRESULT GetArray2([out, satype("LONG")] SAFEARRAY** Arr);
    [id(3), helpstring("method GetArray3")] HRESULT GetArray3([out, size_is(ArrElements)] LONG* Arr, [in] int ArrElements);
};

1 and 2 work, 3 does not.  In LV GetArray3's first parameter is just a LONG value.  Any way to make the pointer to array argument work in LV?  I've seen some functions being imported into LV like MoveBlock, is that a possibility? 




0 Kudos
Message 1 of 3
(2,746 Views)
Hi,

Do you mind clarifying a little what you are trying to do?  Are you trying to pass the array to or from LabVIEW?  What exactly do you mean by "test COM?"

You may have already run across these, but take a look at some of the following links:

Passing a Variety of Data Types from DLL to LabVIEW
Converting a LabVIEW String to a Character Array and Passing its Pointer to a Call Library Function ...
What are the Differences Between "Array Data Pointer", "Array Handle", and "Array Handle Pointer"?
MoveBlock
Pointers to Pointers, MoveBlock, and Stability
Pointer to Array
Eric C.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(2,713 Views)
My goal was to pass arrays in both directions: client to server and server back to client.  In the case above an array would be created by the client and passed to the server (the dll) to be filled in with data.  If not using SafeArrays this would require allocating the array by Labview, which I was unsuccessful at doing.  "test COM dll" means a small dll written for testing purposes of this problem with a COM interface.

I ended up using SAFEARRAYS in my project dll.
0 Kudos
Message 3 of 3
(2,661 Views)