A Simple COM Tutorial

Published February 02, 2001 by Odin Jensen, posted by Myopic Rhino
Do you see issues with this article? Let us know.
Advertisement
For a quick test run ComTest\Debug\ComTest.exe (Run Install Components.bat first!)

To Uninstall the components run Uninstall.bat

This simple COM tutorial just creates to fictive "renders" as COM objects and shows how to select a between different components that support the same interface.

Disclaimer: This has nothing to do with a real render. It's only a COM test.

Important: COM interfaces cannot change, or you must create a completely new interface and still retain the old one. (Like DirectX) As long as you don't alter the interface you can change the code to your heart's content without requiring a recompile of the client that uses the component. If two apps use the same component it's only loaded once and unloaded when all are done using it via refcounting.

API hint: If you have different components for each API, don't expose it to the outside world. That way a user of, say, the DirectX8 render will only need the runtime and not the SDK. (+ that's the whole point of one interface and different implementations :)

Common pitfall: Don't forget to include a *.def file or exported functions can't be seen by COM.

If you have questions mail [email="com_me@nukesoftware.com"]com_me@nukesoftware.com[/email]

Have fun and make component based systems :)

Odin Jensen
Lead Programmer
Nuke Software
Cancel Save
0 Likes 0 Comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!

Provides a brief explanation of COM and an example program using it.

Advertisement
Advertisement
Advertisement