CreateObject equivalent in C/C++? (COM Interop)

c, c++, com, interop

Solution

It's the CoCreateInstance() function.

It is convenient to use CoCreateInstance when you need to create only a single instance of an object on the local machine. If you are creating an instance on remote computer, call CoCreateInstanceEx. When you are creating multiple instances, it is more efficient to obtain a pointer to the class object's IClassFactory interface and use its methods as needed. In the latter case, you should use the CoGetClassObject function.

You'll need to #include <Objbase.h> and you'll need to link to ole32.lib

Problem

What would the equivalent in C/C++?

Original source