This function copies the source array to the target array after releasing any resources in the target array. This function is similar to SafeArrayCopy, except that the target array has to be set up by the caller. The target is not allocated or reallocated.

HRESULT SafeArrayCopyData(
  SAFEARRAY FAR* psaSource, 
  SAFEARRAY FAR* FAR* psaTarget 


  • psaSource
    [in] Pointer to the safearray to be copied.
  • psaTarget
    [out] On exit, a pointer to the array referred to by psaTarget that contains a copy of the data in psaSource.

Return Values

The following table shows the HRESULT values that can be returned by this function.

Value Description
S_OK Success.
E_INVALIDARG The psa parameter was not a valid safearray descriptor.
E_OUTOFMEMORY Insufficient memory to create the copy.


Visual Basic for Applications and Automation use the same set of rules with cases in which the size or types of source and destination arrays do not match. The rules of Visual Basic are described in the following comments. Passing invalid (and under some circumstances NULL) pointers to this function causes an unexpected termination of the application.


OS Versions: Windows CE 2.0 and later.
Header: Oleauto.h.
Link Library: Oleaut32.lib.

See Also


Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.