From RAD Studio API Documentation
Jump to: navigation, search


function SafeArrayCreate(VarType, DimCount: Integer; const Bounds: TVarArrayBoundArray): PVarArray;
function SafeArrayCreate(VarType, DimCount: Integer; Bounds: PVarArrayBoundArray): PVarArray; external oleaut name 'SafeArrayCreate';


Type Visibility Source Unit Parent
function public System.VarUtils.pas System.VarUtils System.VarUtils


Creates a safe array.

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.

See Also

Code Examples