Share via


COMVariant Class

Definition

The COMVariant class is used as a generic class that can store different types of data. The class is used to pass arguments to the methods or properties of a COM (Component Object Model) Automation object and is used with the COM and COMDispFunction classes.

public ref class COMVariant : Microsoft::Dynamics::Ax::Xpp::XppObjectBase
[Microsoft.Dynamics.Ax.Xpp.KernelClass]
[Microsoft.Dynamics.BusinessPlatform.SharedTypes.InternalUseOnly]
public class COMVariant : Microsoft.Dynamics.Ax.Xpp.XppObjectBase
[<Microsoft.Dynamics.Ax.Xpp.KernelClass>]
[<Microsoft.Dynamics.BusinessPlatform.SharedTypes.InternalUseOnly>]
type COMVariant = class
    inherit XppObjectBase
Public Class COMVariant
Inherits XppObjectBase
Inheritance
Microsoft.Dynamics.AX.KernelInterop.ProxyBase
COMVariant
Attributes
KernelClassAttribute Microsoft.Dynamics.BusinessPlatform.SharedTypes.InternalUseOnlyAttribute

Remarks

The data type of the COMVariant object can be set by:

  • The new method
  • The variantType method
  • The createFrom methods. For example, the createFromBoolean method creates a COMVariant object of type VT_BOOL (= Boolean).
  • The property methods. For example, if you set a new value by using the boolean property, and the object is not of type VT_BOOL (= Boolean), it will be changed to this type.

The value of the data type is set by one of the property methods. For example, the value of a COMVariant object of type VT_BOOL is set by the boolean method. The possible data types and the methods that set their values are listed in the Remarks section. The data types that the COMVariant class supports are not X++ data types, but data types defined by the COM Automation standard. The COMVariant class is based on the VARIANT structure found in the Win32 SDK. For more information see the Win32 SDK documentation. The property methods of the COMVariant class map to the COMVariantType values in the following way:

boolean VT_BOOL
bStr VT_BSTR String data type
byte VT_UI1
char VT_I1
currency VT_CY
date, time VT_DATE Date/time data type; both properties must be set.
decimal VT_DECIMAL
double VT_R8
float VT_R4
iDispatch VT_DISPATCH
int, long VT_I4 VT_I4 is used for both the int and the long data types
iUnknown VT_UNKNOWN
sCode VT_ERROR The scode data type is a COM data type that is equivalent to the Win32 HRESULT data type.
short VT_I2
uInt, uLong VT_UI4 VT_UI4 is used for both the uInt and the uLong data types
uShort VT_UI2
variant VT_VARIANT
safeArray VT_SAFEARRAY Array data type

The following example instantiates a COM object that exposes a method called multiply which multiplies two floating point numbers passed in as COMVariant parameters.

{ 
    COM com; 
    COMVariant varArg1 = new COMVariant(); 
    COMVariant varArg2 = new COMVariant(); 
    COMVariant varRet; 
    real ret; 
    InteropPermission perm; 
    // Set code access permission to help protect the use  
    // of the COM object. 
    perm = new InteropPermission(InteropKind::ComInterop); 
    if (perm == null) 
    { 
        return; 
    } 
    // Permission scope starts here 
    perm.assert(); 
        com = new COM("MyCOM.Object"); 
    // Specify arguments for the 'multiply' method 
    varArg1.float(123); 
    varArg2.float(456); 
    varRet = com.multiply(varArg1, varArg2); 
    ret = varRet.double(); 
    // 'ret' is now 56088 (123*456) 
    // Close the code access permission scope. 
    CodeAccessPermission::revertAssert(); 
}

Constructors

COMVariant()
COMVariant(COMVariantInOut, COMVariantType)
COMVariant(COMVariantInOut)
COMVariant(IntPtr)

Fields

__k_COMVariantId
kernelClass (Inherited from XppObjectBase)

Methods

__shouldCallNew(Type)
addXppProxyReference(Type, Object) (Inherited from XppObjectBase)
boolean()

Gets or sets the value of a COMVariant object of the VT_BOOL data type.

boolean(Boolean)
bStr()

Gets or sets the value of a COMVariant object of the VT_BSTR data type.

bStr(String)
byte()

Gets or sets the value of a COMVariant object of the VT_UI1 data type.

byte(Int32)
Call(String, Object[], Type[], Object[]) (Inherited from XppObjectBase)
cancelTimeOut(Int32) (Inherited from XppObjectBase)
char()

Gets or sets the value of a COMVariant object of the VT_I1 data type.

char(Int32)
container()

Gets or sets the value of a COMVariant object of the container data type.

container(Object[], COMVariantType)
container(Object[])
createDateFromYMD(Int32, Int32, Int32, COMVariantInOut)
createDateFromYMD(Int32, Int32, Int32)

Creates a new COMVariant object and initializes it with a date value in one operation.

createFromArray(Array, COMVariantInOut)
createFromArray(Array)

Creates a new COMVariant object and initializes it with an array in one operation.

createFromBoolean(Boolean, COMVariantInOut)
createFromBoolean(Boolean)

Creates a new COMVariant object and initializes it with a Boolean value in one operation.

createFromCOM(COM, COMVariantInOut)
createFromCOM(COM)

Creates a new COMVariant object and initializes it with a COM class in one operation.

createFromDate(Date, COMVariantInOut)
createFromDate(Date)

Creates a new COMVariant object and initializes it with a date value in one operation.

createFromDateAndTime(Date, Int32, COMVariantInOut)
createFromDateAndTime(Date, Int32)

Creates a new COMVariant object and initializes it with a date and time in one operation.

createFromInt(Int32, COMVariantInOut)
createFromInt(Int32)

Creates a new COMVariant object and initializes it with an integer value in one operation.

createFromInt64(Int64, COMVariantInOut)
createFromInt64(Int64)

Creates a new COMVariant object and initializes it with an int64 value (longLong or uLongLong) in one operation.

createFromReal(Decimal, COMVariantInOut)
createFromReal(Decimal)

Creates a new COMVariant object and initializes it with a real value in one operation.

createFromStr(String, COMVariantInOut)
createFromStr(String)

Creates a new COMVariant object and initializes it with a string in one operation.

createFromTime(Int32, COMVariantInOut)
createFromTime(Int32)

Creates a new COMVariant object and initializes it with a time value in one operation.

createFromUtcDateTime(utcdatetime, COMVariantInOut)
createFromUtcDateTime(utcdatetime)
createKernelClass(Object[], Type[], Object[]) (Inherited from XppObjectBase)
createNoValue()

Creates a COMVariant object of the VT_ERROR variant type with no value.

currency()

Gets or sets the value of a COMVariant object of the VT_CY data type.

currency(Decimal)
date()

Gets or sets the date part of the value of a COMVariant object of the VT_DATE data type.

date(Date)
decimal()

Gets or sets the value of a COMVariant object of the VT_DECIMAL data type.

decimal(Decimal)
double()

Gets or sets the value of a COMVariant object of the VT_R8 data type.

double(Decimal)
equal(XppObjectBase) (Inherited from XppObjectBase)
finalize()

Not implemented. You can override this method if you need to explicitly destruct an object.

float()

Gets or sets the value of a COMVariant object of the VT_R4 data type.

float(Decimal)
GetIntPtr() (Inherited from XppObjectBase)
GetKernelInstanceUniqueId() (Inherited from XppObjectBase)
getTimeOutTimerHandle() (Inherited from XppObjectBase)
getXppProxyReference(Type) (Inherited from XppObjectBase)
handle()
iDispatch()

Gets or sets the value of a COMVariant object of the VT_DISPATCH data type.

iDispatch(Int64)
int()

Gets or sets the value of a COMVariant object of the VT_I4 data type.

int(Int32)
IsManagedValid() (Inherited from XppObjectBase)
iUnknown()

Gets or sets the value of a COMVariant object of the VT_UNKNOWN (IUnknown) data type.

iUnknown(Int64)
kernelhandle()
KernelInstanceDisposed() (Inherited from XppObjectBase)
long()

Gets or sets the value of a COMVariant object of the VT_I4 data type.

long(Int32)
longLong()

Gets or sets the value of a COMVariant object of the VT_I8 (longlong) data type.

longLong(Int64)
MakeReflectionCall(String, Object[]) (Inherited from XppObjectBase)
newmethod()

Creates a COMVariant object that can be used to pass arguments to the methods or properties of a COM Automation object.

newmethod(COMVariantInOut, COMVariantType)
newmethod(COMVariantInOut)
notify() (Inherited from XppObjectBase)
notifyAll() (Inherited from XppObjectBase)
noValue()

Deletes the contents of an existing COMVariant object and enables it to act as an unspecified argument when it is used in the COMDispFunction.call method or the COM class.

objectOnServer()
Obsolete.
(Inherited from XppObjectBase)
safeArray()

Gets or sets the value of a COMVariant object of the VT_SAFEARRAY data type.

safeArray(Array, COMVariantType)
safeArray(Array)
sCode()

Gets or sets the value of a COMVariant object of the VT_ERROR data type.

sCode(Int32)
setTimeOut(String, Int32, Boolean)
Obsolete.
(Inherited from XppObjectBase)
setTimeOut(String, Int32)
Obsolete.
(Inherited from XppObjectBase)
short()

Gets or sets the value of a COMVariant object of the VT_I2 (short) data type.

short(Int32)
time()

Gets or sets the time part of the value of a COMVariant object of the VT_DATE data type.

time(Int32)
ToString()

Creates a string representation of a COMVariant object. This string representation includes the value and type of the object.

uInt()

Gets or sets the value of a COMVariant object of the VT_UI4 data type.

uInt(Int32)
uLong()

Gets or sets the value of a COMVariant object of the VT_UI4 (unsigned long) data type.

uLong(Int32)
uLongLong()

Gets or sets the value of a COMVariant object of the VT_UI8 (unsigned longlong) data type.

uLongLong(Int64)
usageCount() (Inherited from XppObjectBase)
uShort()

Gets or sets the value of a COMVariant object of the VT_UI2 data type.

uShort(Int32)
variant()

Gets or sets the value of a COMVariant object of the VT_VARIANT (variant) data type.

variant(COMVariant)
variantInOutFlag()

Sets or returns the InOutFlag setting for a COMVariant object.

variantInOutFlag(COMVariantInOut)
variantType()

Queries a COMVariant object for its variant data type or changes the data type.

variantType(COMVariantType)
VerifyKernelClass() (Inherited from XppObjectBase)
wait() (Inherited from XppObjectBase)
Xml() (Inherited from XppObjectBase)
Xml(Int32) (Inherited from XppObjectBase)

Applies to