ComKoalaDll Example
This version of the Koala example can be linked as an independent DLL. It can be tested with the ObjUser.exe program which is provided with the book "Inside OLE". Note that you have to set the ObjUser.exe program into DLL mode.

The implementation of the DLL only slightly differs from the first ComKoala implementation. One difference is that a counter is provided which counts the number of instances. This counter is incremented whenever a new object is created (CreateInstance method), and it is decremented if the last interface reference is removed (RELEASE finalizer).

Every in-process server must provide the two functions DllGetClassObject and DllCanUnloadNow. The first procedure is called whenever a factory is required, and with the second command it is tested whether the DLL can be unloaded. The DLL can be unloaded if no object generated by a factory of the DLL is referenced through an interface pointer and if no factory of the DLL was locked with the factory's LockServer method.

This ComKoalaDll example can be linked to DKoala1.dll with the following command:

	DevLinker.LinkDll "Com/DKoala1.dll" := Kernel+ ComKoalaDll# ~
	
The registry must be informed about which DLL to launch if a IKoala factory is required. The necessary registry file Com/Reg/DKoala1.reg is given below. Use the REGEDIT tool to update the registry. Adjust path names if necessary!


REGEDIT
HKEY_CLASSES_ROOT\Koala1.0 = Koala Object Chapter 5
HKEY_CLASSES_ROOT\Koala1.0\CLSID = {00021146-0000-0000-C000-000000000046}
HKEY_CLASSES_ROOT\Koala = Koala Object Chapter 5
HKEY_CLASSES_ROOT\Koala\CurVer = Koala1.0
HKEY_CLASSES_ROOT\Koala\CLSID = {00021146-0000-0000-C000-000000000046}

HKEY_CLASSES_ROOT\CLSID\{00021146-0000-0000-C000-000000000046} = Koala Object Chapter 5
HKEY_CLASSES_ROOT\CLSID\{00021146-0000-0000-C000-000000000046}\ProgID = Koala1.0
HKEY_CLASSES_ROOT\CLSID\{00021146-0000-0000-C000-000000000046}\VersionIndependentProgID = Koala
HKEY_CLASSES_ROOT\CLSID\{00021146-0000-0000-C000-000000000046}\InprocServer32 = C:\BlackBox\Com\DKoala1.dll
HKEY_CLASSES_ROOT\CLSID\{00021146-0000-0000-C000-000000000046}\NotInsertable


ComKoalaDllsources
