Implementing a COM+ Resource Dispenser

The following steps outline a general procedure for implementing a COM+ resource dispenser:

  1. Decide on RESTYPID format that categorizes how your resources differ from each other.

  2. Use the Mtxdm.h and Mtxdm.lib header file and library, respectively.

  3. Build a DLL that implements the IDispenserDriver interface and the API you want to expose to applications.

  4. In the startup (DllMain or first call to the dispenser API), call the GetDispenserManager function. This returns a pointer to the dispenser manager's IDispenserManager interface.

  5. Call IDispenserManager::RegisterDispenser, passing a pointer to your implementation of IDispenserDriver. This causes the dispenser manager to create a holder (pooling manager) for your resource dispenser and then return the pointer to your IHolder interface.

  6. Store this pointer so that you can call IHolder::AllocResource and IHolder::FreeResource.

  7. You can now (in response to calls to your API) make calls to AllocResource and FreeResource. AllocResource initially responds by calling back to your CreateResource method, but later AllocResource calls are serviced from the growing pool of resources.

COM+ Resource Dispenser Concepts

COM+ Resource Dispenser Interfaces