Windows apps
Collapse the table of content
Expand the table of content

SafeArrayLock Function

Increments the lock count of an array, and places a pointer to the array data in pvData of the array descriptor.

HRESULT SafeArrayLock(  
  SAFEARRAY *psa  
);

psa

Pointer to an array descriptor created by SafeArrayCreate.

The return value obtained from the returned HRESULT is one of the following.

Return value

Meaning

S_OK

Success.

E_INVALIDARG

The psa parameter is not a valid safe array descriptor.

E_UNEXPECTED

The array could not be locked.

The pointer in the array descriptor is valid until SafeArrayUnlock Function is called. Calls to SafeArrayLock can be nested, in which case an equal number of calls to SafeArrayUnlock Function are required.

An array cannot be deleted while it is locked.

All public static (Shared in Visual Basic) members of the SAFEARRAY data type are thread safe. Instance members are not guaranteed to be thread safe.

For example, consider an application that uses the SafeArrayLock and SafeArrayUnlock Function functions. If these functions are called concurrently from different threads on the same SAFEARRAY data type instance, an inconsistent lock count may be created. This will eventually cause the SafeArrayUnlock Function function to return E_UNEXPECTED. You can prevent this by providing your own synchronization code.

Show:
© 2016 Microsoft