Can non-COM DLLs utilize embeded typelibs for use when importing?

Is it possible to write a non-COM DLL and embeded a type-library like in COM DLLs. It would be nice to distribute a DLL and any developer can use the #import directive and have Visual Studio generate the header files for them from the typelib.

I could have swore I saw this done before, but a colleauge says it is only done for COM DLLs.

Who is Participating?
COM DLLs have the option to embed typelibs. Non COM DLLs have this option as well - and it doesn't require ITypeInfo, or any other COM interfaces to be used.

Embedding typelib information into a dll simply requires an extra resource to be added to the DLL. The resouce being the typelib itself. COM is not requried in order to do this, or extract it - it's simply another resource.

Instructions on how to embed a type library into a DLL as a resource can be found in my posts here:
Well, yes and no. As soon as you can embed and read a typelib, the DLL *is* COM, since it implements ITypeInfo...
code_snakeAuthor Commented:
Interesting. That may be acceptable since that COM feature would only be used for development.

The question is then how does Visual Studio C++ treat the DLL then. Since it is using the ITypeInfo interface it probably does not understand that the DLL does not implement IUnknown or any subinterfaces. In addition, I would guess it can't understand that interfaces that are defined in the typelib are not COM, and need to be called directly on the DLL not through COM.

So it sounds like the the answer is no, is is not possible.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.