简体   繁体   中英

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

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

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

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

Kind regards

如果您使用C ++,我建议您查看ATL,如果使用C,我建议使用C ++。使用#import构造来访问DLL或EXE中的COM对象非常容易。

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

There is a wonderful article at Microsoft that seems to address this exact question. If you want to stick with straight C++ (ie 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM