HRESULT VariantCopy(
VARIANTARG FAR* pvargDest,
VARIANTARG FAR* pvargSrc
);
Frees the destination variant and makes a copy of the source variant.
The return value obtained from the returned HRESULT is one of the following.
Return value | Meaning |
---|---|
S_OK | Success. |
DISP_E_ARRAYISLOCKED | The variant contains an array that is locked. |
DISP_E_BADVARTYPE | The source and destination have an invalid variant type (usually uninitialized). |
E_OUTOFMEMORY | Memory could not be allocated for the copy. |
E_INVALIDARG | One of the arguments is invalid. |
First, free any memory that is owned by pvargDest, such as VariantClear (pvargDest must point to a valid initialized variant, and not simply to an uninitialized memory location). Then pvargDest receives an exact copy of the contents of pvargSrc.
If pvargSrc is a VT_BSTR, a copy of the string is made. If pvargSrc is a VT_ARRAY, the entire array is copied. If pvargSrc is a VT_DISPATCH or VT_UNKNOWN, AddRef is called to increment the object's reference count.
Windows NT: Use version 3.1 and later.
Windows: Use Windows 95 and later.
Header: Declared in oleauto.h.
Import Library: Link with oleaut32.lib.