---
name: "VariantCopy"
section: "3w"
platform: "linux"
package: "libwine-dev"
version: "1.4.1-4"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/VariantCopy"
---

# VariantCopy(3w)

## NAME

**VariantCopy** (OLEAUT32.10)

## SYNOPSIS

HRESULT VariantCopy\
  (\
   VARIANTARG\* *pvargDest*,\
   VARIANTARG\* *pvargSrc*\
  )

## DESCRIPTION

Copy a variant.

## PARAMS

*pvargDest* **\[Out\]**  Destination for copy.

*pvargSrc* **\[In\]**  Source variant to copy.

## RETURNS

**Success:** **S\_OK**. *pvargDest* contains a copy of *pvargSrc*.

**Failure:** **DISP\_E\_BADVARTYPE**, if either variant has an invalid type. **E\_OUTOFMEMORY**, if memory cannot be allocated. Otherwise an **HRESULT** error code from **[SafeArrayCopy(3w)](/SafeArrayCopy/3w.md)**, **IRecordInfo\_GetSize(3w)**, or **IRecordInfo\_RecordCopy(3w)**, depending on the type of *pvargSrc*.

## NOTES

**-** If *pvargSrc* == *pvargDest*, this function does nothing, and succeeds if *pvargSrc* is valid. Otherwise, *pvargDest* is always cleared using VariantClear() before *pvargSrc* is copied to it. If clearing *pvargDest* fails, so does this function.

**-** **VT\_CLSID** is a valid type type for *pvargSrc*, but not for *pvargDest*.

**-** For by-value non-intrinsic types, a deep copy is made, i.e. The whole value is copied rather than just any pointers to it.

**-** For by-value object types the object pointer is copied and the objects reference count increased using **IUnknown\_AddRef(3w)**.

**-** For all by-reference types, only the referencing pointer is copied.

## IMPLEMENTATION

Declared in **"oleauto.h"**.

Implemented in **"dlls/oleaut32/variant.c"**.

Debug channel **"variant"**.
