Table of contents
1.
Introduction
2.
Class Information Classes
2.1.
IProvideClassInfo2Impl Classl
2.1.1.
Methods
2.1.2.
IProvideClassInfo2Impl GetClassInfo Method
2.1.3.
Return Value
2.1.4.
IProvideClassInfo2 GetGUID Method
2.1.5.
Return Value
2.1.6.
Constructor
2.1.7.
Data Members
3.
Frequently Asked Questions
3.1.
What are classes in ATL?
3.2.
What is ATL?
3.3.
What is the use of the IprovideClassInfo2Impl class?
3.4.
What are the two public methods of the IprovideClassInfo2Impl class?
3.5.
Name data member of IprovideClassInfo2Impl class.
4.
Conclusion
Last Updated: Mar 27, 2024
Easy

Class Information Classes

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

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.

Class Information Classes

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;

Frequently Asked Questions

What are classes in ATL?

Classes in Active Template Library(ATL) contain important data to display in different directions like metafile, printer, or ActiveX control. Class instance data in the ATL windowing code.

What is ATL?

Active Template Library is a collection of C++ classes that are template based to make writing Component Object Model(COM) objects easier. 

What is the use of the IprovideClassInfo2Impl class?

The IprovideClassInfo2Impl class under the class information classes gives us access to retrieve and type the information. This class executes IProvideClassInfo and IProvideClassInfo2 methods.

What are the two public methods of the IprovideClassInfo2Impl class?

The two public methods of the IprovideClassInfo2Impl class under class information classes are GetClassInfo and GetGUID.

Name data member of IprovideClassInfo2Impl class.

The IProvideClassInfo2Impl::_tih is a protected data member of the class template parameter, tihclass, which manages the type information for the coclass.

Conclusion

In this article, we discussed the class Information classes (IprovideClassInfo2Impl). We also discussed the methods, constructors, and data members of IprovideClassInfo2Impl. 

Recommended Reading

You can also read about some other related topics such as Bus and Memory Transfer.

Refer to our Guided Path to upskill yourself in DSACompetitive ProgrammingJavaScriptSystem Design, and many more! If you want to test your competency in coding, check out the mock test series and participate in the contests hosted on Coding Ninjas Studio

We wish you Good Luck! 

Happy Learning!

Live masterclass