Module

COM


Description

Classes and functions to deal with COM components (i.e. ActiveX Controls and Automation).

Methods

Name

Parameters

Returns

FreeVARIANT

oleVariant As MemoryBlock

IIDFromString

iidString As String

MemoryBlock

RBVariantToVARIANT

v As Variant, addByref As Boolean = False

MemoryBlock

StringFromIID

iid As Ptr

String

VARIANTToRBVariant

oleVar As Ptr

Variant

Method descriptions


COM.FreeVARIANT

FreeVARIANT(oleVariant As MemoryBlock)

Frees an OLE VARIANT.

' oleVar holds an OLE VARIANT which contains a BSTR that needs to be freed
Var oleVar As MemoryBlock = COM.RBVariantToVARIANT("test")

' ... use oleVar

COM.FreeVARIANT( oleVar )

' Note: it is ok to free any type of OLE VARIANT, for example,
'       if the OLE VARIANT contains an Integer, calling FreeVARIANT is harmless

COM.IIDFromString

IIDFromString(iidString As String) As MemoryBlock

Converts an IID string representation of the form {B1EFC382-9355-11D0-835C-00AA003CCABD} to an actual IID.

Var iid As MemoryBlock
iid = COM.IIDFromString( "{B1EFC382-9355-11D0-835C-00AA003CCABD}" )

COM.RBVariantToVARIANT

RBVariantToVARIANT(v As Variant, addByref As Boolean = False) As MemoryBlock

Converts an RB Variant to an OLE VARIANT. If addByref is True then the VARIANT type will include VT_BYREF.

' oleVar holds an OLE VARIANT which contains a BSTR that needs to be freed
Var oleVar As MemoryBlock = COM.RBVariantToVARIANT("test")

' ... use oleVar

COM.FreeVARIANT( oleVar )

COM.StringFromIID

StringFromIID(iid As Ptr) As String

Converts an IID to a string representation of the form {B1EFC382-9355-11D0-835C-00AA003CCABD}.

Var iid As MemoryBlock
iid = COM.IIDFromString( "{21D6D48E-A88B-11D0-83DD-00AA003CCABD}" )

MessageBox COM.StringFromIID( iid )

COM.VARIANTToRBVariant

VARIANTToRBVariant(oleVar As Ptr) As Variant

Converts an OLE VARIANT to an RB Variant.

Var oleVar As MemoryBlock = COM.RBVariantToVARIANT( 2012 )
Var v As Variant = COM.VARIANTToRBVariant( oleVar )

Notes

Refer to the Microsoft COM documentation for full details on all classes, constants, structures, etc. used by COM.


Classes

Each class is described in its own section:

Name

Super Class

Description

IUnknown

The common interface supported by all COM objects

IDispatch

IUnknown

The common interface exposed by Automation servers

IEnumVARIANT

IUnknown

This interface provides a way to enumerate a collection of variants

IPicture

IUnknown

This interface manages a picture object and its properties. Get the details here.

COMException

RuntimeException

Raised when a COM exception is encountered


Result

Class Constant

Description

S_OK

Result returned without error.

S_FALSE

Result returned with an error.


Invoke

These constants can be passed as flags to the IDispatch.Invoke method:

Class Constant

Description

DISPATCH_METHOD

The member is invoked as a method. If a property has the same name, both this and the DISPATCH_PROPERTYGET flag may be set.

DISPATCH_PROPERTYGET

The member is retrieved as a property or data member.

DISPATCH_PROPERTYPUT

The member is changed as a property or data member.

DISPATCH_PROPERTYPUTREF

The member is changed by a reference assignment, rather than a value assignment. This flag is valid only when the property accepts a reference to an object.


Size Constants

These constants represent the sizes of common COM structures:

Class Constant

Description

SIZEOF_PTR

The size in bytes of a pointer. This value is platform-dependent: 4 on 32-bit systems and 8 on 64-bit systems.

SIZEOF_VARIANT

The size in bytes of an OLE VARIANT structure.


Locale Constants

Used to specify the locale for COM calls such as IDispatch.Invoke:

Class Constant

Description

LOCALE_USER_DEFAULT

The default locale for the current user.


Structures

Used for a variety of COM calls. Refer to Microsoft's documentation for details.

Compatibility

Project Types

Console, Desktop, Web

Operating Systems

Windows

See also

COMException exception