This package allows R users to explore type information coming from
either type libraries or COM objects. The functions provide
information about a class in terms of its properties; methods and
their argument and return types; the names and values of enumerated
types, and fields in structures and unions.
One can find type information by loading a type library or by
obtaining a reference to a COM object. Suppose we have the ADO
(ActiveX Data Object) library on our system at it is located at
C:/Program Files/Common Files/system/ado/msado15.dll
We load that library using LoadTypeLib
lib = LoadTypeLib("C:/Program Files/Common Files/system/ado/msado15.dll")
The resulting lib
is a reference or handle to the
C-level structure that identifies the object. We can use this to
examine the different elements about which the library provides type
information. When we are finished with it, we can release the library
and free the resources it uses using UnloadTypeLib
Essentially we can treat the type library as a named list.
Each element is an object of type ITypeInfo in our
world. This provides a reference to the elemenet in the type library
and from that we can find out most things about that type.
Since the library reference is equivalent to a list
in S, we can find out the names
of the different elements it contains.
As one might expect, we can extract elements from the type
library in the S style using either
Now that we know how to navigate the type library,
we can examine its elements.
We can also find out the types of these different elements
This describes the type of each element in the library by its type
name such as dispatch, coclass, enum. These are indexed by the names
of the type. If one wants to get the actual numeric type rather than
the text descriptions (so that they can be used within the C code),
use the byName
argument and specify FALSE
We can ``zoom in'' and look at the type information for individual
elements of the type library. We get a reference to the underlying C
object using the overloaded
can index the type library reference either by the name or position of
the desired element.
We can then get the details of the type of this element using this
object. For example, we can find the collection of values in the
Suppose we wanted to find all the enumerations
within a library and obtain their definitions
as a name-value vector for each enum type.
We can do this in two steps
types = getTypeLibTypes(lib)
enums = which(types == "enum")
lapply(enums, function(x) getEnum(lib[[x]]))
If an element in the type library is a coclass type info object, then
it can represent multiple interfaces. We get a list of the
objects for each of these interfaces by
. We can the operate on each of
elements as we do above. The
function has a recursive
for an article describing aspects of type libraries.