Solved

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

Posted on 2004-10-26
195 Views
Last Modified: 2010-05-18
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.

Thanks.
0
Question by:code_snake
    3 Comments
     
    LVL 86

    Expert Comment

    by:jkr
    Well, yes and no. As soon as you can embed and read a typelib, the DLL *is* COM, since it implements ITypeInfo...
    0
     

    Author Comment

    by:code_snake
    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.
    0
     
    LVL 9

    Accepted Solution

    by:
    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:
    http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20891459.html
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Article by: SunnyDark
    This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
    Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

    857 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now