如何在win32 C ++项目visual studio 2010中使用ActiveX dll

时间:2022-09-01 19:12:07

Background: Vendor has provided me ActiveX Dll, no header files or .tlb file or anything such. I am using Visual Stdio 2010 and using win32 C++.

背景:供应商为我提供了ActiveX Dll,没有头文件或.tlb文件或类似的东西。我正在使用Visual Stdio 2010并使用win32 C ++。

The problem I am facing is how to load or reference dll?

我面临的问题是如何加载或引用DLL?

I cannot reference the dll through solution explorer because it is unmanaged project. When I try to use #import, it give me compile error saying XXX.tlb file not found. But I don't have .tlb type file. The other option I tried was to open the dll with OLE viewer and copy the dll definitions and then paste in .idl extension file I created with Visual Studio. Then I executed midl on the idl file to create .h file but that did not help either. When I try use the classes, its gives me "abstract classes cannot be used or referenced" error.

我无法通过解决方案资源管理器引用dll,因为它是非托管项目。当我尝试使用#import时,它会给我编译错误,说找不到XXX.tlb文件。但是我没有.tlb类型的文件。我尝试的另一个选项是使用OLE查看器打开dll并复制dll定义,然后粘贴我使用Visual Studio创建的.idl扩展文件。然后我在idl文件上执行midl来创建.h文件,但这也没有帮助。当我尝试使用类时,它给我“抽象类不能使用或引用”错误。

There are other questions asked on the matter but not straight forward and the answers are not marked as answered or upvoted.

关于此事还有其他问题,但不是直截了当的,答案没有标记为已回答或已投票。

I want to know what are the different methods available to load the ActiveX dll in win32 C++ project in visual studio 2010 and which one should be preferred when? If there is a thread that actually addresses my issue please point me to that.

我想知道在visual studio 2010中在win32 C ++项目中加载ActiveX dll有哪些不同的方法,哪一个应该是首选?如果有一个线程实际上解决了我的问题,请指出我。

Thanks

2 个解决方案

#1


4  

If you are able to see the interface definitions using OLE View it means that the type library is embedded into the dll resources. So if you use #import "YourActiveX.dll" it should work.

如果您能够使用OLE视图查看接口定义,则意味着类型库嵌入到dll资源中。因此,如果你使用#import“YourActiveX.dll”它应该工作。

#2


0  

You need

  1. Register the COM (Active X) component in windows using regsvr32 : regsvr32 my_dll.dll
  2. 使用regsvr32:regsvr32 my_dll.dll在Windows中注册COM(Active X)组件

  3. Then use COM to interact with the component. This is a good tutorial.
  4. 然后使用COM与组件进行交互。这是一个很好的教程。

#1


4  

If you are able to see the interface definitions using OLE View it means that the type library is embedded into the dll resources. So if you use #import "YourActiveX.dll" it should work.

如果您能够使用OLE视图查看接口定义,则意味着类型库嵌入到dll资源中。因此,如果你使用#import“YourActiveX.dll”它应该工作。

#2


0  

You need

  1. Register the COM (Active X) component in windows using regsvr32 : regsvr32 my_dll.dll
  2. 使用regsvr32:regsvr32 my_dll.dll在Windows中注册COM(Active X)组件

  3. Then use COM to interact with the component. This is a good tutorial.
  4. 然后使用COM与组件进行交互。这是一个很好的教程。