Accessing COM interface from C or C++ in Windows environment

10,991

Solution 1

Actually, you will need to instantiate the object using the COM interface.

This is fairly complicated, more than we can just answer here.

here is a good primer: http://www.codeproject.com/KB/COM/comintro.aspx

Another one: http://www.codeguru.com/cpp/com-tech/activex/tutorials/article.php/c5567

Solution 2

I would suggest looking into ATL if you are using C++, and using C++ if using C. It is very easy to use the #import construct to access COM objects in DLLs or EXEs.

Solution 3

There is a wonderful article at Microsoft that seems to address this exact question. If you want to stick with straight C++ (i.e. MFC/ATL), you should check out the article as it has loads of sample code:

How to automate Excel from C++ without using MFC or #import

Share:
10,991
Aaron
Author by

Aaron

I find bugs

Updated on June 27, 2022

Comments

  • Aaron
    Aaron almost 2 years

    I'm relatively new to the Component Object Model specification - I have a simple question:

    • How can I access a COM interface from a C or C++ application

    For instance, accessing Microsoft Excel COM interface to perform basic operations, without user intervention.

    Kind regards

  • cbrulak
    cbrulak over 15 years
    but that is not really what this person is asking.
  • Steve Steiner
    Steve Steiner over 15 years
    While kenny may not have answered what was asked, he did give an answer to the underlying problem, which is often more valuable.
  • Aaron
    Aaron over 15 years
    Where can I find examples, using ATL with C++ - Thanks in advance