From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing arrays from labview to VC++

I have a method "MyFunc" in my ActiveX component(VC++)
It expects a pointer to a variant as parameter
The variant type is needs to be VT_I4|VT_BYREF

In my VI I created and array using "build array" with 6 long integers as input. How do I make this thing work

Thanks
0 Kudos
Message 1 of 4
(2,539 Views)
I believe LabVIEW passes arrays by pointer anyway. If LabVIEW does not let you wire the array directly to the variant input of the method, or if there are problems when you run it, try converting the array to variant using the Variant VI's in the Advanced- Data manipulation pallete.
0 Kudos
Message 2 of 4
(2,539 Views)
Here is the method I am calling from labview

STDMETHODIMP HRESULT CRunStatus::SetRunStatusProperties(VARIANT *pRunStatusProperties)
{
// Validate that the passed pointer in fact points to an array of longs
if (((pRunStatusProperties.vt & VT_I4) != 0) && ((pRunStatusProperties.vt & VT_BYREF) != 0))
{
//do domething
}
}

The method expects a pointer to a variant of type reference to an long array

To my knowledge labview(base package) has no way of doing this. It can only pass as a "safe array".

Please correct me if I am wrong
0 Kudos
Message 3 of 4
(2,539 Views)
I found a hack for my problem. All the arrays from labview are passed to the ActiveX components as SAFEARRAYs. So the variant has to treat the type as a VT_ARRAY.

I think a c-style array(VT_I4|VT_BYREF) can be passed using CINTools. I havent tried this approach

Will post back when I find out the solution 🙂
0 Kudos
Message 4 of 4
(2,539 Views)