Index   Commented   Search   About

SafeArrayAllocDescriptor

(cDims, ppsaOut)
unsigned int cDims
SAFEARRAY FAR* FAR* ppsaOut

Allocates memory for a safe array descriptor.

Parameters

cDims

The number of dimensions of the array.

ppsaOut

Pointer to a location in which to store the created array descriptor.

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.

Comments

This function lets you create safe arrays containing 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 and call SafeArrayAllocData to allocate memory for the array elements.

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

Related Links

Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
TMS Scripter Studio Pro components for Delphi/C++Builder

More Online Helps

Win32 Programmer's Reference (win32.hlp)
Win32 Multimedia Programmer's Reference (mmedia.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (sock2.hlp)
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008 Free Tect Secrets ;) greatis just4fun network just4fun