C++ Class Parameters - C/C++ DLL Call Parameters

C++ Class Parameters

If you create a C++ DLL using National Instruments Measurement Studio in Microsoft Visual Studio, you can pass TestStand data to Measurement Studio class objects. The following table shows the supported C++ classes and the corresponding data types you can pass.

(64-bit TestStand) Measurement Studio data types ( CNiVector , CNiMatrix , CNiComplex , CNiComplexVector , CNiBoolVector , CNiString ) are not supported.

Category Compatible TestStand Type
CNiVector Array of Numbers (one-dimensional)
CNiMatrix Array of Numbers (two-dimensional)
CNiComplex Two Numbers
CNiComplexVector Two Arrays of Numbers (one-dimensional)
CNiBoolVector Array of Booleans (one-dimensional)
CNiString String
CString String
CStringArray Array of Strings (one-dimensional)
_bstr_t String

If the Visual Studio project is not a Measurement Studio project, you can pass data to the CString , CStringArray , and _bstr_t classes. To add support for these classes to the DLL, include the tsdllparams.cpp source file, located in the <TestStand> \API\VC directory, in a single source file in the project.

The CNiVector , CNiMatrix , CNiComplex , or CNiComplexVector categories contain the same data types as the Numeric category. Each of these categories correspond to Measurement Studio C++ template, for which the Type control specifies the template argument. The following table shows the Measurement Studio classes that correspond to each TestStand category and type.

Category Type Setting Measurement Studio Class
CNiVector Signed 8-bit Integer CNiInt8Vector
Unsigned 8-bit Integer CNiUInt8Vector
Signed 16-bit Integer CNiInt16Vector
Unsigned 16-bit Integer CNiUInt16Vector
Signed 32-bit Integer CNiInt32Vector
Unsigned 32-bit Integer CNiUInt32Vector
32-bit Real Number CNiReal32Vector
64-bit Real Number CNiReal64Vector
CNiMatrix Signed 8-bit Integer CNiInt8Vector
Unsigned 8-bit Integer CNiUInt8Matrix
Signed 16-bit Integer CNiInt16Matrix
Unsigned 16-bit Integer CNiUInt16Matrix
Signed 32-bit Integer CNiInt32Matrix
Unsigned 32-bit Integer CNiUInt32Matrix
32-bit Real Number CNiReal32Matrix
64-bit Real Number CNiReal64Matrix
CNiComplex Signed 8-bit Integer CNiComplexInt8
Unsigned 8-bit Integer CNiComplexUInt8
Signed 16-bit Integer CNiComplexInt16
Unsigned 16-bit Integer CNiComplexUInt16
Signed 32-bit Integer CNiComplexInt32
Unsigned 32-bit Integer CNiComplexUInt32
32-bit Real Number CNiComplexReal32
64-bit Real Number CNiComplexReal64
CNiComplexVector Signed 8-bit Integer CNiComplexInt8Vector
Unsigned 8-bit Integer CNiComplexUInt8Vector
Signed 16-bit Integer CNiComplexInt16Vector
Unsigned 16-bit Integer CNiComplexUInt16Vector
Signed 32-bit Integer CNiComplexInt32Vector
Unsigned 32-bit Integer CNiComplexUInt32Vector
32-bit Real Number CNiComplexReal32Vector
64-bit Real Number CNiComplexReal64Vector

Pass by Value or by Reference

When you select one of the C++ classes as the category for a parameter, the C/C++ DLL Adapter displays the Pass control. This control specifies whether TestStand passes the value of the argument you specify in the Value Expression control or passes a pointer to the argument. If you select By Pointer (*) , By Const Pointer (const*) , By Reference (&) , or By Const Reference (const &) , the C/C++ DLL Adapter passes a pointer to the argument value.

Before calling the DLL function, TestStand constructs a temporary C++ class object of the selected type and initializes the object with the argument value. If you choose to pass by value, TestStand passes the temporary object to the DLL function on the call stack. When the DLL function returns, TestStand does not copy the data of the function back to the TestStand argument.

If you choose to pass a pointer, TestStand passes a pointer to the temporary object to the DLL function. If you specify By Pointer (*) or By Reference (&), TestStand copies the object data back to the TestStand argument when the DLL function returns. In this case, the argument you specify in the Value Expression control must be the name of a variable or property. TestStand destroys the temporary object after the DLL function returns.

Note You can pass NULL to a C++ class pointer parameter by passing an empty object reference or the constant Nothing . Do not pass the constant 0 .

See Also

Mapping Parameters

Microsoft Visual C++/#import