MULTAPP: Multi-Instance DLL with Separate Data

MULTAPP creates a multi-instance dynamic-link library
(DLL) that maintains separate data for each task that
links to it. A task is identified by the value of its
stack segment (SS). Data for each task is stored in a
block of memory obtained through GlobalAlloc. When a task
calls a function in the DLL, the DLL looks up the task in
its list and gets the segment (selector) of the global
memory block that contains the data for that task. The
segment address is then placed into the DS register. After
this point, all static data and the local heap are
specific to the task that called the DLL.

MULTAPP provides menu options for entering data into the
DLL's data segment, retrieving data from the DLL's data
segment, and filling the local heap with data items.

The first time a task calls into the DLL, a new block of
memory is allocated for the task's data. The initial
values for the static variables are copied into the block
and a local heap is initialized.

When a task that has called into the DLL shuts down, it
must call the UnregisterTask function. This function
removes the task from the DLL's list and frees the data
associated with the task. If the task does not call
UnregisterTask, another task with the same SS as the first
task might link to the DLL. Since the first task did not
unregister itself, the SS will be associated with a DS
that is no longer present, and will cause a UAE.

MULTAPP was built and tested under Microsoft(R)
Windows(TM) version 3.1.

KEYWORDS: PR-CD2; LocalReAlloc; LocalAlloc; LocalLock;
LocalUnLock; GlobalSize; GlobalAlloc; GlobalLock; _fmemcpy
