Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function does the following:
- Creates an array descriptor
- Allocates and initializes the data for the array
- Retrieves a pointer to the new array descriptor
Syntax
SAFEARRAY * SafeArrayCreate( VARTYPE vt, unsigned int cDims, SAFEARRRAYBOUND FAR* rgsabound ); |
Parameters
- vt
-
[in] Base type of the array (the VARTYPEof each element of the array). The VARTYPEis restricted to a subset of the variant types.
Neither 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.
- cDims
-
[in] Number of dimensions in the array.
The number cannot be changed after the array is created.
- rgsabound
-
[in] Pointer to a vector of bounds (one for each dimension) to allocate for the array.
Return Value
Returns a pointer to a SAFEARRAYstructure.
Remarks
Passing invalid (and under some circumstances NULL) pointers to this function causes an unexpected termination of the application. When implementing this function, test the legitimacy of the return value, as in the following sample code.
Example
Copy Code | |
---|---|
HRESULT PASCAL __export CPoly::EnumPoints(IEnumVARIANT FAR* FAR* ppenum) { unsigned int i; HRESULT hresult; VARIANT var; SAFEARRAY FAR* psa; CEnumPoint FAR* penum; POINTLINK FAR* ppointlink; SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; rgsabound[0].cElements = m_cPoints; psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound); if(psa == NULL){HRESULT = ReportResult(0, E_OUTOFMEMORY, 0, 0); goto LError0} // Code omitted here for brevity. LError0:; return hresult; } |
Requirements
Header | oleauto.h |
Library | oleaut32.lib |
Windows Embedded CE | Windows CE 2.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |