2

I have developed a C++ DLL-based COM object that implements some IUnknown derived interface. How can I use it in VB6? Does VB6 support IUnknown based interfaces, or I need to derive from IDispatch?

UPDATE

I have not used ATL. The implementation is based on A very simple COM server without ATL or MFC article. Seems like I need to generate a .tlb file for my object?!

2 Answers 2

3

You do not need to use IDispatch; that's only required for late binding.

To use your object you must add a reference to the object's type library to your VB6 project.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your answer! It is good that I do not need to implement all this stuff from IDispatch. I have updated my question. Don't you know a way to generate a TLB file without MIDL or MkTypLib?
Why can't you use MIDL? Defining an interface and coclass in MIDL is a standard part of using COM in C/C++, it doesn't require the use of MFC or ATL.
It is because (1) I am using MinGW compiler, (2) The MIDL output is littered with meaningless code and comments - I don't like it.
You don't necessarily have to use the .c and .h files MIDL creates; as long as you ensure the interface definitions and GUIDs match what your C++ code uses, it should work. I'm not aware of any other way to generate TLB files.
3

If the interface is only derived from IUnknown and not IDispatch , you can use early binding in VB6.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.