The object handler must contain a function that copies the OLEOBJECTVTBL from the OLECLI.DLL to the object handler. Do not attempt to modify the original OLEOBJECTVTBL in the OLECLI.DLL as other objects may be using it while your handler is in operation. The CopyVTBL function (or your renamed variation) is called from every object-creation function in the handler.
The CopyVTBL function must do the following:
Make a working copy of OLEOBJECTVBL
Save the pointer to the original OLEOBJECTVTBL
Change the pointers in the working copy to point to your new object-creation functions
The following pseudocode shows the structure of the CopyVTBL function. When the handler is created, a pointer to OLEOBJECT is passed to the handler (lpobj).
CopyVTBL (lpobj)
{
lpvtblDef = lpobj->lpvtbl;/* Original OLEOBJECTVTBL */
vtblDLL = *lpobj->lpvtbl;/* Make copy of OLEOBJECTVTBL */
vtblDLL.Draw = DllDraw;/* change individual pointer */
vtblDLL.GetData = DllGetData;/* change another pointer */
}
Note Only the pointers for the individual object-manipulation functions that will appear in the object handler must be changed. The new object-manipulation functions do not need to have the Dll prefix; any name can be used as long as it is exported, since OLEOBJECTVTBL will point to the modified function when called by the OLE APIs in OLECLI.DLL.