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

# VarCmp(3w)

## NAME

**VarCmp** (OLEAUT32.176)

## SYNOPSIS

HRESULT VarCmp\
  (\
   LPVARIANT *left*,\
   LPVARIANT *right*,\
   LCID      *lcid*,\
   DWORD     *flags*\
  )

## DESCRIPTION

Compare two variants.

## PARAMS

*left* **\[In\]**  First variant.

*right* **\[In\]**  Second variant.

*lcid* **\[In\]**  **LCID** (locale identifier) for the comparison.

*flags* **\[In\]**  Flags to be used in the comparison: **NORM\_IGNORECASE**, **NORM\_IGNORENONSPACE**, **NORM\_IGNORESYMBOLS**, **NORM\_IGNOREWIDTH**, **NORM\_IGNOREKANATYPE**, **NORM\_IGNOREKASHIDA**.

## RETURNS

VARCMP\_LT: *left* variant is less than *right* variant. VARCMP\_EQ: input variants are equal. VARCMP\_GT: *left* variant is greater than *right* variant. VARCMP\_NULL: either one of the input variants is **NULL**.

**Failure:** An **HRESULT** error code indicating the error.

## NOTES

Native VarCmp up to and including WinXP doesn't like **I1**, **UI2**, **VT\_UI4**, **UI8** and **UINT** as input variants. **INT** is accepted only as *left* variant.

If both input variants are **ERROR** then **VARCMP\_EQ** will be returned, else an **ERROR** variant will trigger an error.

Both input variants can have **VT\_RESERVED** flag set which is ignored unless one and only one of the variants is a **BSTR** and the other one is not an **EMPTY** variant. All four **VT\_RESERVED** combinations have a different meaning:

**-** **BSTR** and other: **BSTR** is always greater than the other variant.

**-** **BSTR**\|VT\_RESERVED and other: a string comparison is performed.

**-** **BSTR** and other\|VT\_RESERVED: If the **BSTR** is a number a numeric comparison will take place else the **BSTR** is always greater.

**-** **BSTR**\|VT\_RESERVED and other\|VT\_RESERVED: It seems that the other variant is ignored and the return value depends only on the sign of the **BSTR** if it is a number else the **BSTR** is always greater. A positive **BSTR** is greater, a negative one is smaller than the other variant.

## SEE

VarBstrCmp for the *lcid* and *flags* usage.

## IMPLEMENTATION

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

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

Debug channel **"variant"**.
