COM Notes Example Code

<< Contents >>

Simple Server
Simple Client


This is basically the minimum code to create a COM DLL server and a COM client. There is next to no commenting as I wrote these as a "first attempt". This code is only to remind myself what an actual implementation looks like for those "I'm sure I've done everything... what have I missed" and "that documentation could be taken several ways" moments.

Simple Server

Demonstrates a very simple DLL server supporting the DaveComponent class which has two interfaces (IJack and IClavdivs - Sorry!). Full source including .reg file that needs to be merged with the registry (note: you'll need to modify this so that the Inproc32Server line points to wherever you have placed the DLL). Also includes the Simple Client
ClassFactory.cpp The class factory and its implementation of IClassFactory
COM.cpp The entry points / DLL code (DllMain, DllGetClassObject etc.)
Object.cpp DaveComponent and it implementation of IUnknown, IJack and IClavdivs

Headers can accessed through hyperlinks in the CPP files, but are listed here for convince: ClassFactory.h, COM.h, dave_i_c.h, Object.h, stdafx.h, and dave_idl_i.c. Also available are the MIDL file and the DLL export def file.


Simple Client

Demonstrates a very simple console based client for the above server.

COMClient.cpp Uses DaveComponent.

Headers can accessed through hyperlinks in the CPP files.