Search code examples
c++.netcom

How to create a simple COM component in C++


How to create a simple COM component in C++, and then to consume it in my C# project.

I don't want to use ATL. Are there any simple step by step instructions or a complete procedure to get started. (I have done googling but not found any desired content).

Any help will be appreciated.


Solution

    1. empty DLL project
    2. exports from the DLL to be used by COM: DllGetClassObject and friends
    3. implementation of COM object factory
    4. implementation of the COM object itself
    5. type library is recommended to be embedded for better integration with C#
    6. COM object registration

    All steps assume understanding of COM basics, of course. ATL covers most of this right from the start, a project created from template is taking you immediately to details of #4 above.

    If you are looking for some sample to start from, you can find pretty close ones: