SafeArrayCreateVector

This function creates a one-dimensional array whose lower bound is always zero. A safe array created with SafeArrayCreateVector is a fixed size, so the constant FADF_FIXEDSIZE is always set.

At a Glance

Header file: Oleauto.h
Windows CE versions: 2.0 and later

Syntax

HRESULT SafeArrayCreateVector(VARTYPE vt, long lLbound,
unsigned int cElements);

Parameters

vt

Base type of the array (the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types for the array. All other types are legal.

lLbound

Lower bound for the array; can be negative.

cElements

Number of elements in the array.

Return Values

A pointer to the array descriptor indicates success. NULL indicates that the array could not be created.

Remarks

SafeArrayCreateVector allocates a single block of memory that contains a SAFEARRAY structure for a single-dimension array (24 bytes), immediately followed by the array data. All of the existing safe array functions work correctly for safe arrays that are allocated with SafeArrayCreateVector.

A SafeArrayCreateVector is allocated as a single block of memory. Both the SafeArray descriptor and the array data block are allocated contiguously in one allocation, which speeds up array allocation. However, a user can allocate the descriptor and data area separately using the SafeArrayAllocDescriptor and SafeArrayAllocData calls. Passing into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application.