Dwight Schrute
Dwight Schrute

Reputation: 369

How to use ActiveX dll in win32 C++ project visual studio 2010

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++.

The problem I am facing is how to load or reference 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.

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.

Thanks

Upvotes: 2

Views: 8031

Answers (2)

Isso
Isso

Reputation: 1333

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.

Upvotes: 4

Preet Sangha
Preet Sangha

Reputation: 65556

You need

  1. Register the COM (Active X) component in windows using regsvr32 : regsvr32 my_dll.dll
  2. Then use COM to interact with the component. This is a good tutorial.

Upvotes: 0

Related Questions