RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
VarUtils.SafeArrayCreate Function

Creates a safe array.

Pascal
function SafeArrayCreate(VarType: Integer; DimCount: Integer; const Bounds: TVarArrayBoundArray): PVarArray; stdcall;
C++
__stdcall PVarArray SafeArrayCreate(int VarType, int DimCount, const TVarArrayBoundArray Bounds);

Use SafeArrayCreate to create a safe array with the given parameters.  

The VarType parameter gives the type of each element in the safe array. Use the var... constants (varInteger, varBoolean, varDate, varCurrency and so on) in the System unit to specify the elements' variant type.  

The DimCount parameter gives the safe array's number of dimensions. DimCount also represents the number of elements in the Bounds constant array.  

Bounds is a constant TVarArrayBoundArray type giving the bound information of the safe array, in all its dimensions.  

In order to create the safe array, SafeArrayCreate first checks whether the element type is valid, then allocates memory for the safe array descriptor using the SafeArrayAllocDescriptor function. Finally, it attempts to allocate memory for the actual data of the safe array, using SafeArrayAllocData. If this is not successful, then it destroys the previously allocated descriptor using the SafeArrayDestroyDescriptor routine.  

If SafeArrayCreate managed to create the safe array, then it returns a pointer to the array as a PVarArray type variable. In the case when SafeArrayCreate did not manage to create the safe array, it simply returns nil.  

To destroy a safe array, use the SafeArrayDestroy function. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!