C++

C++ – Operator Overloading

One of the beautiful feature of ‘C++’ is it’s ability to support Operator Overloading. ‘C++’ Operator Overloading allows to change the behavior of operators when using them with ‘C++’ class objects. One of the best example of Operator Overloading is ‘+’ operator. Usually ‘+’ operator will add two integer operands and produce an integer result. […]

C++ – Inheritance – to extend class

Inheritance allows reusing the functionality. Inheritance inherits base class members to its derived class. We can use base class members within the derived class without rewriting the base class code. C++ allows single inheritance as well as multiple inheritances. In single inheritance, the derived class is inherited from a single base class. In multiple inheritances, […]

COM – Creating a COM Component using C++ – Add Type Library to Visual Basic Application

In our previous article, we have created Type Library “Hello.tlb”. We were facing issues when we tried to add “HelloComponent.dll” as a reference to our Visual Basic test application. Hence we have created “Hello.tlb” Type Library. And we observed that even with “Hello.tlb” Type Library, Visual Basic test application (console based application) is showing error […]

COM – Creating a COM Component using C++ – Summary of component development

Finally we have successfully developed our COM component HelloComponent using C++. Lets summarize how we developed our COM component in this article. Microsoft’s Component Object Model (COM) is a specification to allow to write re-usable components and enables them to communicate each other. COM depends on interfaces to achieve its goals. One of the main interface is […]

C++: Templates

C++ Templates are used for writing generic programming. C++ allows to define function templates and class templates. In C++, we use template keyword to write generic programming. The syntax of the template declaration starts with template<class T> Where template is the keyword which indicates the particular function or class is a generic function or class. Here […]

COM – Creating a COM Component using C++ – IClassFactory implementation

CoCreateInstance depends on IClassFactory to create class instances. We have looked into IClassFactory‘s methods and we have implemented these methods in our previous article. Let’s include IClassFactory‘s implementation into our HelloComponent. We already have HelloComponent‘s declaration in the “HelloComponent.h” file and its implementation in the “HelloComponent.cpp” file. In the same way, we will add the IClassFactory […]

COM – Creating a COM Component using C++ – IClassFactory

In our previous article, we have identified that CoCreateFunction is requesting an instance of IClassFactory. Why CoCreateInstance is requesting an instance of IClassFactory? One of the goals of the COM is to locate the objects easily without worrying about where they are located and where they are housed; whether they are housed in in-process, local, or remote. in-process means, the […]

COM – Creating a COM Component using C++ – Inside CoCreateInstance

As we discussed in our previous articles, COM’s CoCreateInstance function is used to create instances for COM classes. What is happening inside the CoCreateInstance function? When the client program calls CoCreateInstance to create an instance of COM class: It actually internally calls another function CoGetClassObject CoGetClassObject checks the registry entries for CLSID which was passed through […]

Scroll to top