Equivalent to CreateObject in C / C ++? (COM Interop)

What would be equivalent in C / C ++?

+6
c ++ c interop com
source share
3 answers

This is the function CoCreateInstance () .

It is convenient to use CoCreateInstance when you need to create only one instance of an object on the local machine. if you are creating an instance on a remote computer, call CoCreateInstanceEx. When you create several cases, it is more efficient to get a pointer to an object of the IClassFactory Interface class and use it if necessary. In the latter case, you should use the CoGetClassObject function.

You will need #include <Objbase.h> and you will need to set the link to ole32.lib

+11
source share

Only two calls. You need CLSIDFromProgID () to map the argument that you usually pass CreateObject to the CLSID. Which you can then use in CoCreateInstance ().

+6
source share

Remember to call CoInitializeEx or CoInitialize before CoCreateInstance

+5
source share

All Articles