HRESULT SafeArrayAllocDescriptor(
unsigned int cDims,
SAFEARRAY FAR* FAR* ppsaOut
);
Allocates memory for a safe array descriptor.
The return value obtained from the returned HRESULT is one of the following.
Return value | Meaning |
---|---|
S_OK | Success. |
E_INVALIDARG | The argument psa was not a valid safe array descriptor. |
E_UNEXPECTED | The array could not be locked. |
This function allows the creation of safe arrays that contain elements with data types other than those provided by SafeArrayCreate. After creating an array descriptor using SafeArrayAllocDescriptor, set the element size in the array descriptor, an call SafeArrayAllocData to allocate memory for the array elements.
The following example creates a safe array using the SafeArrayAllocDescriptor and SafeArrayAllocData functions.
SAFEARRAY FAR* FAR*ppsa;
unsigned int ndim = 2;
HRESULT hresult = SafeArrayAllocDescriptor( ndim, ppsa );
if( FAILED( hresult ) )
return ERR_OutOfMemory;
(*ppsa)->rgsabound[ 0 ].lLbound = 0;
(*ppsa)->rgsabound[ 0 ].cElements = 5;
(*ppsa)->rgsabound[ 1 ].lLbound = 1;
(*ppsa)->rgsabound[ 1 ].cElements = 4;
hresult = SafeArrayAllocData( *ppsa );
if( FAILED( hresult ) ) {
SafeArrayDestroyDescriptor( *ppsa )
return ERR_OutOfMemory;
}
Windows NT: Use version 3.1 and later.
Windows: Use Windows 95 and later.
Header: Declared in oleauto.h.
Import Library: Link with oleaut32.lib.
SafeArrayAllocData, SafeArrayDestroyData, SafeArrayDestroyDescriptor