From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function SafeArrayLock; external oleaut name 'SafeArrayLock';


extern "C" HRESULT __stdcall SafeArrayLock(System::PVarArray VarArray);


Type Visibility Source Unit Parent
function external public
System.VarUtils System.VarUtils


Locks a safe array.

SafeArrayLock locks the safe array given through the VarArray parameter. VarArray is a pointer to the safe array.

The possible return values of SafeArrayLock are listed in the following table, together with their meaning.

Value Meaning


The operation was completed successfully.


The given argument is nil.


The array given through VarArray is locked.

While locked, a safe array cannot be resized and any calls to SafeArrayRedim fail. Once locked, a safe array must later be unlocked using SafeArrayUnlock.

If the locking operation succeeded, VarArray points to an array of elements in which the leftmost dimension increases first. In other words, the dimensions of the returned array pointer are reversed from the dimensions of the safe array.

Tip: Once SafeArrayLock verifies that the safe array has the correct bounds and dimensions, SafeArrayLock can be used to gain direct access to the array data, which results in improved performance.

See Also