Admin Production ni-theme
Current Publication

CA_Array2DToSafeArray

LabWindows/CVI

CA_Array2DToSafeArray

HRESULT CA_Array2DToSafeArray (const void *array, unsigned int arrayType, size_t numberOfElementsInDim1, size_t numberOfElementsInDim2, LPSAFEARRAY *safeArray);

Purpose

Creates a safe array from a 2D array and stores a pointer to the safe array in safeArray.

Use CA_SafeArrayDestroy to free the returned safe array.

Parameters

Input
Name Type Description
array const void * 2D array to convert into a safe array.

CA_Array2DToSafeArray does not make copies of BSTR, VARIANT, LPUNKNOWN, or LPDISPATCH elements. CA_Array2DToSafeArray copies the pointers from array into the created safe array. When you call CA_SafeArrayDestroy, which frees all contents of the safe array, the BSTR, VARIANT, LPUNKNOWN, or LPDISPATCH elements in array become invalid.
arrayType unsigned int Data type of the elements in array.

arrayType can contain any of the fundamental data types for variants, safe arrays, and properties except for CAVT_EMPTY, CAVT_NULL, or CAVT_OBJHANDLE.
numberOfElementsInDim1 size_t Number of elements of the first dimension of array.

This function returns an error if you pass a value greater than UINT_MAX.
numberOfElementsInDim2 size_t Number of elements in the second dimension of array.

This function returns an error if you pass a value greater than UINT_MAX.
Output
Name Type Description
safeArray LPSAFEARRAY Safe array that CA_Array2DToSafeArray creates from the contents of array.

Use CA_SafeArrayDestroy to free the returned safe array.

Return Value

Name Type Description
status HRESULT A value indicating whether an error occurred. Negative error codes indicate function failure.

Error codes are defined in CVIversion\include\cviauto.h and <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h. The LabWindows/CVI ActiveX Library explicitly returns error codes. Other error codes in winerror.h are generated by ActiveX servers and passed on to you by the LabWindows/CVI ActiveX Library.

You can use CA_GetAutomationErrorString to get the description of an error code or CA_DisplayErrorInfo to display the description of the error code.

Additional Information

Library: ActiveX Library

Include file: cviauto.h

LabWindows/CVI compatibility: LabWindows/CVI 5.0 and later