SafeArrayAllocData

(psa)
SAFEARRAY FAR* psa

Allocates memory for a safe array based on a descriptor created with SafeArrayAllocDescriptor.

Parameters

psa

Pointer to an array descriptor created by SafeArrayAllocDescriptor.

Return Value

The SCODE obtained from the returned HRESULT is one of the following:

SCODE
Meaning
S_OK
Success.
E_INVALIDARG
The argument psa was not a valid safe array descriptor.
E_UNEXPECTED
The array could not be locked.

Example

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;

}

See Also

SafeArrayAllocData
, SafeArrayDestroyData, SafeArrayDestroyDescriptor

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples