使用C ++或C访问应用程序的COM接口 [英] Accessing an application's COM interface using C++ or C

查看:139
本文介绍了使用C ++或C访问应用程序的COM接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

回答问题时,如何从C ++(或C)使用以下方法(或找到更多信息)自动化某些功能 p>


  • ATL

  • 或自动代码直接在C / C ++中



    • 注意

      解决方案

      如果应用程序公开了类型库应用程序),那么你可以从Microsoft C ++通过使用#import关键字。这将为应用程序公开的COM接口创建C ++包装。



      类型库通常是.TLB文件,但它们通常作为Win32资源嵌入可执行文件中。 / p>

      要确定应用程序是否以这种方式公开其功能,您可能需要查阅特定应用程序的文档,因为发现(和理解)类型库相当复杂。



      Windows SDK包括一个工具OLE / COM Viewer,可以显示注册表中COM对象的类型库信息,或者从.TLB文件或资源。



      如果你想玩一个应用程序,VBScript(或JScript)给你一个快速的实验方法。他们都能够消费OLE自动化接口。


      In response to question, how can I (or find more information to) automate certain functionality without user intervention, from a C++ (or C) using:

      • ATL
      • Or Automation code directly in C/C++

      Regards

      解决方案

      If the application exposes a type library (and Microsoft Office applications do), then you can get at it from Microsoft C++ by using the #import keyword. This will create C++ wrappers for the COM interfaces exposed by the application.

      Type libraries are often .TLB files, but they are regularly embedded as Win32 resources in executable files.

      To find out if an application exposes its functionality in this way, you'll probably need to consult the documentation for the specific application, because discovering (and understanding) type libraries is quite complicated.

      The Windows SDK includes a tool, "OLE/COM Viewer" that can display typelibrary information for a COM object in the registry, or from a .TLB file or resource.

      If you want to play with an application, VBScript (or JScript) give you a quick way to experiment. They're both capable of consuming OLE Automation interfaces.

      这篇关于使用C ++或C访问应用程序的COM接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆