[英]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: 我对组件对象模型规范比较陌生 - 我有一个简单的问题:
For instance, accessing Microsoft Excel COM interface to perform basic operations, without user intervention. 例如,访问Microsoft Excel COM接口以执行基本操作,无需用户干预。
Kind regards 亲切的问候
如果您使用C ++,我建议您查看ATL,如果使用C,我建议使用C ++。使用#import构造来访问DLL或EXE中的COM对象非常容易。
Actually, you will need to instantiate the object using the COM interface. 实际上,您需要使用COM接口实例化对象。
This is fairly complicated, more than we can just answer here. 这是相当复杂的,我们可以在这里回答。
here is a good primer: http://www.codeproject.com/KB/COM/comintro.aspx 这是一本很好的入门书: http : //www.codeproject.com/KB/COM/comintro.aspx
Another one: http://www.codeguru.com/cpp/com-tech/activex/tutorials/article.php/c5567 另一个: 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:
如果你想坚持使用直接C ++(即MFC / ATL),你应该查看文章,因为它有大量的示例代码:
How to automate Excel from C++ without using MFC or #import 如何在不使用MFC或#import的情况下从C ++自动化Excel
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.