Introduction
In this article, we will learn about one of the classes in Microsoft Active Template Library. Active Template Library is a collection of C++ classes that are template based to make writing Component Object Model(COM) objects easier. With the help of ATL, the object wizard sets up a structure of objects with just a few lines of code.

In this blog, we will discuss the topic of Class Information Classes in detail. Let's start.
Class Information Classes
Only one class supports the class Information, which is known as the IprovideClassInfo2Impl class.
IProvideClassInfo2Impl Classl
The IprovideClassInfo2Impl class under class information classes gives us access to retrieve and type the information. This class executes IProvideClassInfo and IProvideClassInfo2 methods. The interface IProvideClassInfo2 extends IProvideClassInfo by adding the GetGUID method.
The syntax to use class information classes as IprovideClassInfo2Impl is:
template <const CLSID* pcoclsid, const IID* psrcid,
const GUID* plibid = &CAtlModule::m_libid,
WORD wMajor = 1,
WORD wMinor = 0, class tihclass = CComTypeInfoHolder>
class ATL_NO_VTABLE IProvideClassInfo2Impl : public IProvideClassInfo2
psrcid
It is a pointer for coclass' default outgoing dispinterface.
pcoclsid
It is a pointer that points to a coclass identifier.
wMajor
It is a major version of the type library, and the default value for this is '1'.
plibid
It is a pointer of the type library(Contains information about the interface) that points to the LIBID, and by default, the server-level type library is passed.
wMinor
It is a minor version of the type library, and the default value for this is '0'.
tihclass
This class has a default value of CComTypeInfoHolder. It is used to manage the coclass' type information.
The type information for the coclass is managed by CComTypeInfoHolder, which is a static member of the IprovideClassInfo2Impl class.
Methods
There are two public methods in the Class Information Classes. Let's discuss each of them in detail.
IProvideClassInfo2Impl GetClassInfo Method
It retrieves a pointer for the object's type information. The object's coclass entry in the type library(Where information is there) matches with the type information for an object.
If the object loads the type information from the type library, then the type library will call the AddRef method(Increments reference count) in creating the pointer.
The syntax is as follows:
HRESULT GetClassInfo(
[out] ITypeInfo **ppTI
);
[out] ppTI
It is a pointer to an ITypeInfo pointer variable that will receive the interface pointer to the object's type information.
Return Value
This method can return the below values along with E_UNEXPECTED and E_OUTOFMEMORY.
Return Value |
Meaning |
S_OK | The method is completed successfully. |
E_POINTER | The address in ppTI can be null or any invalid address. |
IProvideClassInfo2 GetGUID Method
Its use is to retrieve the specified GUID for the object.
HRESULT GetGUID(
[in] DWORD dwGuidKind,
[out] GUID *pGUID
);
[in] dwGuidKind
It is a GUID type, where the possible values are from the GUIDKIND enumeration.
[out] pGUID
It is a pointer that points to a variable that receives the GUID.
Return Value
This method can return the standard values E_UNEXPECTED, E_INVALIDARG, E_POINTER, and S_OK.
Constructor
IProvideClassInfo2Impl is the constructor of the IProvideClassInfo2Impl class under class information classes. It calls the AddRef on the _tih member.
Syntax:
IProvideClassInfo2Impl();
Data Members
The IProvideClassInfo2Impl::_tih is a protected data member of the class template parameter, tihclass, which manages the type information for the coclass.
static tihclass
_tih;