Stoserve: Structured Storage in an In-Process Server

Click to open or copy the Stoserve project files.

Click to open or copy the Include files (required).

Click to open or copy the Library files (required).

Note   To use this sample, you must first build the Register sample.

The primary focus of the Stoserve sample is on the use of OLE structured storage services as provided in the OLE compound files implementation. Stoserve works with the Stoclien code sample to illustrate the joint use of compound file storage by client and server.

The Stoserve sample introduces the COPaper COM object, which models a sheet of white drawing paper. COPaper objects expose a set of features for free-form drawing on the paper surface using "ink" of specified color and width. The functionality is outwardly similar to other Scribble tutorials in Visual C++ tutorial samples. The difference in the Stoserve/Stoclien samples is an architecture based primarily on OLE technology. The electronic drawing paper features of COPaper objects are available to clients through a custom IPaper interface. COPaper implements the IPaper interface. A clear architectural distinction is kept between client and server. No graphical user interface (GUI) is provided by COPaper. The design of the COPaper object relies on the client for all GUI behavior. COPaper encapsulates only the server-based capture and storage of the drawn ink data.

The ink data that is drawn on the COPaper surface can be stored in and loaded from OLE compound files. The IPaper Save and Load methods accept an IStorage interface pointer. COPaper uses this client-provided IStorage interface to store the drawing data.

COPaper is housed in an in-process server and is made publicly available as a custom COM component. Like all other servers in these COM samples, Stoserve is a self-registering COM server. It makes the COPaper object type available to clients as the DllPaper component using a CLSID_DllPaper registration in the Registry.

As is the case with the Conserve server, connectable object features are supported in COPaper. The IConnectionPointContainer interface is exposed, and an appropriate connection point is implemented. In this context, an outgoing custom IPaperSink interface is declared for use in sending notifications to the client.

The IPaper and IPaperSink custom interfaces are declared in IPAPER.H located in the common sibling \INC directory. The GUIDs for the interfaces and objects are defined in PAPGUIDS.H located in that same common include directory.

The CThreaded facility in Apputil is used by Stoserve to achieve thread safety, as it is in the Freserve sample. COPaper objects are derived from the CThreaded class and inherit its OwnThis and UnOwnThis methods. These methods allow only one thread at a time to have access to the Stoserve server and to COPaper objects managed by the server.

See the parent topic, COM Tutorial Samples, to download global tutorial files or any HTML files about this sample.

Building SDK Samples

This sample uses the following keywords:

addref; addregnamedvalue; advise; canunloadnow; cfpaper; cimpiclassfactory; cimpiconnectionpointcontainer; cimpipaper; clone; coconnectionpoint; coenumconnectionpoints; coenumconnections; copaper; createinstance; createstream; cserver; defined; delete_pointer; dllcanunloadnow; dllgetclassobject; dllmain; dllregisterserver; dllunregisterserver; enumconnectionpoints; enumconnections; erase; erased; failed; findconnectionpoint; findslot; getconnectioninterface; getconnectionpointcontainer; getlasterror; getmodulefilename; getslot; getusername; initpaper; inkdraw; inkstart; inkstop; load; loaded; lock; locked; lockserver; lstrcat; lstrcpy; lstrlen; makelong; memcpy; memset; next; nextslot; notifysinks; objectsdown; objectsup; openstream; ownthis; queryinterface; redraw; regclosekey; regcreatekeyex; regdeletekey; registerclipboardformat; regopenkeyex; regsetvalueex; release; release_interface; reset; resize; resized; rgb; save; saved; setregkeyvalue; skip; stdentry_; stdmethodimp_; stringfromguid2; succeeded; text; unadvise; unicodeok; unlock; unlocked; unownthis; writeclassstg; writefmtusertypestg; wsprintf