Compartilhar via


COleVariant Class

Encapsulates the VARIANT data type.

class COleVariant : public tagVARIANT

Members

Public Constructors

Name

Description

COleVariant::COleVariant

Constructs a COleVariant object.

Public Methods

Name

Description

COleVariant::Attach

Attaches a VARIANT to a COleVariant.

COleVariant::ChangeType

Changes the variant type of this COleVariant object.

COleVariant::Clear

Clears this COleVariant object.

COleVariant::Detach

Detaches a VARIANT from a COleVariant and returns the VARIANT.

COleVariant::GetByteArrayFromVariantArray

Retrieves a byte array from an existing variant array.

COleVariant::SetString

Sets the string to a particular type, typically ANSI.

Public Operators

Name

Description

COleVariant::operator LPCVARIANT

Converts a COleVariant value into an LPCVARIANT.

COleVariant::operator LPVARIANT

Converts a COleVariant object into an LPVARIANT.

COleVariant::operator =

Copies a COleVariant value.

COleVariant::operator ==

Compares two COleVariant values.

COleVariant::operator <<, >>

Outputs a COleVariant value to CArchive or CDumpContext and inputs a COleVariant object from CArchive.

Remarks

This data type is used in OLE automation. Specifically, the DISPPARAMS Data Type structure contains a pointer to an array of VARIANT structures. A DISPPARAMS structure is used to pass parameters to IDispatch::Invoke Method.

Note

This class is derived from the VARIANT structure. This means you can pass a COleVariant in a parameter that calls for a VARIANT and that the data members of the VARIANT structure are accessible data members of COleVariant.

The two related MFC classes COleCurrency and COleDateTime encapsulate the variant data types CURRENCY (VT_CY) and DATE (VT_DATE). The COleVariant class is used extensively in the DAO classes; see these classes for typical usage of this class, for example CDaoQueryDef and CDaoRecordset.

For more information, see the VARIANT, CURRENCY, DISPPARAMS Data Type, and IDispatch::Invoke Method entries in the Windows SDK.

For more information on the COleVariant class and its use in OLE automation, see "Passing Parameters in OLE Automation" in the article Automation.

Inheritance Hierarchy

tagVARIANT

COleVariant

Requirements

Header: afxdisp.h

See Also

Reference

Hierarchy Chart