diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/oleutest/server1 | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/oleutest/server1')
-rw-r--r-- | private/oleutest/server1/csrvapp.cxx | 294 | ||||
-rw-r--r-- | private/oleutest/server1/ctestcf.cxx | 176 | ||||
-rw-r--r-- | private/oleutest/server1/ctestemb.cxx | 227 | ||||
-rw-r--r-- | private/oleutest/server1/daytona/makefile | 10 | ||||
-rw-r--r-- | private/oleutest/server1/daytona/sources | 80 | ||||
-rw-r--r-- | private/oleutest/server1/dirs | 38 | ||||
-rw-r--r-- | private/oleutest/server1/idataobj.cxx | 306 | ||||
-rw-r--r-- | private/oleutest/server1/ioleobj.cxx | 629 | ||||
-rw-r--r-- | private/oleutest/server1/ipersist.cxx | 251 | ||||
-rw-r--r-- | private/oleutest/server1/testsrv.cxx | 204 | ||||
-rw-r--r-- | private/oleutest/server1/testsrv.hxx | 386 | ||||
-rw-r--r-- | private/oleutest/server1/testsrv.ico | bin | 0 -> 766 bytes | |||
-rw-r--r-- | private/oleutest/server1/testsrv.rc | 3 |
13 files changed, 2604 insertions, 0 deletions
diff --git a/private/oleutest/server1/csrvapp.cxx b/private/oleutest/server1/csrvapp.cxx new file mode 100644 index 000000000..b8792c308 --- /dev/null +++ b/private/oleutest/server1/csrvapp.cxx @@ -0,0 +1,294 @@ +//+------------------------------------------------------------------- +// File: csrvapp.cxx +// +// Contents: Implementation of CTestServerApp +// +// Classes: CTestServerApp +// +// History: 17-Dec-92 DeanE Created +// 31-Dec-93 ErikGav Chicago port +// 25-Apr-95 BruceMa CoRevokeClassObject before shutting down +//--------------------------------------------------------------------- +#pragma optimize("",off) +#include <windows.h> +#include <ole2.h> +#include "testsrv.hxx" +#include <except.hxx> + +void ProcessCmdLine(LPSTR, BOOL *); + +// Used to send a quit message +extern HWND g_hwndMain; + + +//+-------------------------------------------------------------- +// Function: CTestServerApp::CTestServerApp +// +// Synopsis: Constructor - initialize members +// +// Parameters: None +// +// Returns: None +// +// History: 17-Dec-92 DeanE Created +//--------------------------------------------------------------- +CTestServerApp::CTestServerApp() +{ + _pteClassFactory = NULL; + _dwRegId = 0; + _fRegistered = FALSE; + _fInitialized = FALSE; + _fEmbedded = TRUE; + _cEmbeddedObjs = 0; +} + + +//+-------------------------------------------------------------- +// Function: CTestServerApp::~CTestServerApp +// +// Synopsis: Insure pointers are free - note this is mainly for +// error-checking. +// +// Parameters: None +// +// Returns: None +// +// History: 17-Dec-92 DeanE Created +//--------------------------------------------------------------- +CTestServerApp::~CTestServerApp() +{ + Win4Assert(_pteClassFactory == NULL && + "Class factory should have been released"); +} + + +//+-------------------------------------------------------------- +// Function: CTestServerApp::InitApp +// +// Synopsis: Initialize this instance of the app. +// +// Parameters: [lpszCmdline] - Command line of the application. +// +// Returns: S_OK if everything was initialized, or an error if not. +// +// History: 17-Dec-92 DeanE Created +// +// Notes: If this does not return, the CloseApp method should +// still be called for proper cleanup. +//--------------------------------------------------------------- +SCODE CTestServerApp::InitApp(LPSTR lpszCmdline) +{ + SCODE sc; + + // Check OLE version running + // BUGBUG - NYI by OLE + // Bail out if we are not running with an acceptable version of OLE + + // Process Command Line arguments + ProcessCmdLine(lpszCmdline, &_fEmbedded); + + // Look up the thread mode from the win.ini file. + DWORD thread_mode; + TCHAR buffer[80]; + int len; + + len = GetProfileString( TEXT("TestSrv"), + TEXT("ThreadMode"), + TEXT("MultiThreaded"), + buffer, + sizeof(buffer) / sizeof(TCHAR)); + + if (lstrcmp(buffer, TEXT("ApartmentThreaded")) == 0) + { + thread_mode = COINIT_APARTMENTTHREADED; + sc = CoInitialize(NULL); + } + else + { +#ifdef MULTI_THREADING + thread_mode = COINIT_MULTITHREADED; + sc = CoInitializeEx(NULL, thread_mode); +#else + // multi-threading not supported + sc = E_INVALIDARG; +#endif + } + + if (S_OK == sc) + { + _fInitialized = TRUE; + } + else + { + return(sc); + } + + // Create the applications class factory - note that we have to free + // at a later time + _pteClassFactory = CTestEmbedCF::Create(this); + if (NULL == _pteClassFactory) + { + return(E_ABORT); + } + + // Register the class with OLE + sc = CoRegisterClassObject( + CLSID_TestEmbed, + _pteClassFactory, + CLSCTX_LOCAL_SERVER, + REGCLS_MULTIPLEUSE, + &_dwRegId); + if (S_OK == sc) + { + _fRegistered = TRUE; + } + + return(sc); +} + + +//+-------------------------------------------------------------- +// Function: CTestServerApp::CloseApp +// +// Synopsis: Clean up resources this instance of the app is using. +// +// Parameters: None +// +// Returns: S_OK if everything was cleaned up, or an error if not. +// +// History: 17-Dec-92 DeanE Created +//--------------------------------------------------------------- +SCODE CTestServerApp::CloseApp() +{ + // Release this apps class factory, and insure the returned count is 0 + if (NULL != _pteClassFactory) + { + if (0 == _pteClassFactory->Release()) + { + _pteClassFactory = NULL; + } + else + { + // BUGBUG - Log error + } + } + + // Uninitialize OLE only if OleInitialize succeeded + if (TRUE == _fInitialized) + { + CoUninitialize(); + } + return(S_OK); +} + + +//+-------------------------------------------------------------- +// Function: CTestServerApp::GetEmbeddedFlag +// +// Synopsis: Returns TRUE if app was started for an embedded object, +// FALSE if standalone. +// +// Parameters: None +// +// Returns: BOOL (_fEmbedded) +// +// History: 17-Dec-92 DeanE Created +// +// Notes: BUGBUG - This should be an inline method +//--------------------------------------------------------------- +CTestServerApp::GetEmbeddedFlag() +{ + return(_fEmbedded); +} + + +//+-------------------------------------------------------------- +// Function: CTestServerApp::IncEmbeddedCount +// +// Synopsis: Increments the count of embedded objects the server +// has open. +// +// Parameters: None +// +// Returns: ULONG (_cEmbeddedObjs) +// +// History: 17-Dec-92 DeanE Created +// +// Notes: BUGBUG - This should be an inline method +//--------------------------------------------------------------- +ULONG CTestServerApp::IncEmbeddedCount() +{ + return(++_cEmbeddedObjs); +} + + +//+-------------------------------------------------------------- +// Function: CTestServerApp::DecEmbeddedCount +// +// Synopsis: Decrements the count of embedded objects the server +// has open. If 0 are left and we were running for an +// embedded object(s), shut down. +// +// Parameters: None +// +// Returns: ULONG (_cEmbeddedObjs) +// +// History: 17-Dec-92 DeanE Created +// +//--------------------------------------------------------------- +ULONG CTestServerApp::DecEmbeddedCount() +{ + if ((0 == --_cEmbeddedObjs) && _fEmbedded) + { + // Revoke the class object, if registered + if (TRUE == _fRegistered) + { + CoRevokeClassObject(_dwRegId); +// OutputDebugStringA("Revoking class object now!\n"); + } + + // Shut down the app + SendMessage(g_hwndMain, WM_USER, 0xFFFFFFFF, 0xFFFFFFFF); + } + + return(_cEmbeddedObjs); +} + + +//+-------------------------------------------------------------- +// Function: ProcessCmdline +// +// Synopsis: Checks the cmd line parameters, in particular for +// '/Embedding' or '-Embedding'. +// +// Parameters: [lpszCmdLine] - Command line buffer. +// [pfEmbedded] - Flag should be set to true if we get +// the '/Embedding' switch. +// +// Returns: void +// +// History: 25-Nov-92 DeanE Created +// +// Notes: Only two valid commandlines for this program: +// (1) -Embedding when started by OLE or (2) Null +// string if started from the command line. +//--------------------------------------------------------------- +void ProcessCmdLine(LPSTR lpszCmdline, BOOL *pfEmbedded) +{ + if (lpszCmdline[0] == 0) + { + *pfEmbedded = FALSE; + return; + } + + if (strcmp(lpszCmdline, "-Embedding") == 0) + { + *pfEmbedded = TRUE; + return; + } + + Win4Assert(!"testsrv received an invalid command line!"); + *pfEmbedded = FALSE; + + return; +} diff --git a/private/oleutest/server1/ctestcf.cxx b/private/oleutest/server1/ctestcf.cxx new file mode 100644 index 000000000..28171ce44 --- /dev/null +++ b/private/oleutest/server1/ctestcf.cxx @@ -0,0 +1,176 @@ +//+------------------------------------------------------------------- +// File: ctestcf.cxx +// +// Contents: +// +// Classes: CTestEmbedCF - IClassFactory +// +// History: 7-Dec-92 DeanE Created +//--------------------------------------------------------------------- +#pragma optimize("",off) +#include <windows.h> +#include <ole2.h> +#include "testsrv.hxx" + +//+------------------------------------------------------------------- +// Member: CTestEmbedCF::CTestEmbedCF() +// +// Synopsis: The constructor for CTestEmbedCF. +// +// Arguments: None +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +CTestEmbedCF::CTestEmbedCF(CTestServerApp *ptsaServer) : _cRef(1) +{ + _ptsaServer = ptsaServer; + + return; +} + + +//+------------------------------------------------------------------- +// Member: CTestEmbedCF::~CTestEmbedCF() +// +// Synopsis: The destructor for CTestEmbedCF. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +CTestEmbedCF::~CTestEmbedCF() +{ + _ptsaServer = NULL; +} + + +//+------------------------------------------------------------------- +// Member: CTestEmbedCF::Create() +// +// Synopsis: Creates a new CTestEmbedCF object. +// +// Arguments: None +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +IClassFactory FAR* CTestEmbedCF::Create(CTestServerApp *ptsaServer) +{ + CTestEmbedCF FAR* pteCF = new FAR CTestEmbedCF(ptsaServer); +// if (NULL != pteCF) +// { +// _ptsaServer = ptsaServer; +// } + return(pteCF); +} + + +//+------------------------------------------------------------------- +// Method: CTestEmbedCF::QueryInterface +// +// Synopsis: Only IUnknown and IClassFactory supported +// return pointer to the actual object +// +// Parameters: [iid] - Interface ID to return. +// [ppv] - Pointer to pointer to object. +// +// Returns: S_OK if iid is supported, or E_NOINTERFACE if not. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CTestEmbedCF::QueryInterface(REFIID iid, void FAR * FAR * ppv) +{ + if (GuidEqual(iid, IID_IUnknown) || GuidEqual(iid, IID_IClassFactory)) + { + *ppv = this; + AddRef(); + return(S_OK); + } + else + { + *ppv = NULL; + return(E_NOINTERFACE); + } +} + +STDMETHODIMP_(ULONG) CTestEmbedCF::AddRef(void) +{ + return ++_cRef; +} + +STDMETHODIMP_(ULONG) CTestEmbedCF::Release(void) +{ + ULONG cRefs = --_cRef; + + if (cRefs == 0) + { + delete this; + } + + return cRefs; +} + + + + + +//+------------------------------------------------------------------- +// Method: CTestEmbedCF::CreateInstance +// +// Synopsis: This is called by Binding process to create the +// actual class object. +// +// Parameters: [pUnkOuter] - Ignored. Affects aggregation. +// [iidInterface] - Interface ID object should support. +// [ppv] - Pointer to the object. +// +// Returns: S_OOM if object couldn't be created, or SCODE from +// QueryInterface call. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CTestEmbedCF::CreateInstance( + IUnknown FAR *pUnkOuter, + REFIID iidInterface, + void FAR* FAR *ppv) +{ + CTestEmbed FAR *pteObj; + SCODE sc; + + pteObj = new FAR CTestEmbed(); + if (pteObj == NULL) + { + return(E_OUTOFMEMORY); + } + sc = pteObj->InitObject(_ptsaServer, g_hwndMain); + if (S_OK != sc) + { + delete pteObj; + return(E_OUTOFMEMORY); + } + + // Having created the actual object, ensure desired + // interfaces are available. + // + sc = pteObj->QueryInterface(iidInterface, ppv); + + + // We are done with the CTestEmbed instance - it's now referenced by ppv + pteObj->Release(); + + return(sc); +} + +//+------------------------------------------------------------------- +// Method: CTestEmbedCF::LockServer +// +// Synopsis: What does this do? +// +// Parameters: [fLock] - ??? +// +// Returns: ??? +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CTestEmbedCF::LockServer(BOOL fLock) +{ + // BUGBUG - What does this do? + return(E_FAIL); +} diff --git a/private/oleutest/server1/ctestemb.cxx b/private/oleutest/server1/ctestemb.cxx new file mode 100644 index 000000000..fc8f56a83 --- /dev/null +++ b/private/oleutest/server1/ctestemb.cxx @@ -0,0 +1,227 @@ +//+------------------------------------------------------------------- +// File: ctestemb.cxx +// +// Contents: CTestEmbed class implementation. +// +// Classes: CTestEmbed +// +// History: 7-Dec-92 DeanE Created +//--------------------------------------------------------------------- +#pragma optimize("",off) +#include <windows.h> +#include <ole2.h> +#include "testsrv.hxx" + + + +//+------------------------------------------------------------------- +// Method: CTestEmbed::CTestEmbed +// +// Synopsis: Constructor for CTestEmbed objects +// +// Parameters: None +// +// Returns: None +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +CTestEmbed::CTestEmbed() : _cRef(1) +{ + _ptsaServer = NULL; + _pDataObject = NULL; + _pOleObject = NULL; + _pPersStg = NULL; + _hwnd = NULL; +} + + +//+------------------------------------------------------------------- +// Method: CTestEmbed::~CTestEmbed +// +// Synopsis: Performs cleanup for CTestEmbed objects by releasing +// internal pointers. +// +// Parameters: None +// +// Returns: None +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +CTestEmbed::~CTestEmbed() +{ + // Inform controlling server app this object is gone + _ptsaServer->DecEmbeddedCount(); + + // Delete all of this objects interface classes + delete _pDataObject; + delete _pOleObject; + delete _pPersStg; +} + + +//+------------------------------------------------------------------- +// Method: CTestEmbed::InitObject +// +// Synopsis: Initialize this CTestEmbed object - ie, set everything +// up for actual use. +// +// Parameters: None +// +// Returns: S_OK if everything is okay to use, or an error code +// +// History: 7-Dec-92 DeanE Created +// +// Notes: The state of the object must be cleaned up in case of +// failure - so the destructor will not blow up. +//-------------------------------------------------------------------- +SCODE CTestEmbed::InitObject(CTestServerApp *ptsaServer, HWND hwnd) +{ + SCODE sc = S_OK; + + // Initialize controlling server app + if (NULL != ptsaServer) + { + _ptsaServer = ptsaServer; + } + else + { + sc = E_ABORT; + } + + // Initilize this objects window handle + _hwnd = hwnd; + + // Create a CDataObject + if (SUCCEEDED(sc)) + { + _pDataObject = new CDataObject(this); + if (NULL == _pDataObject) + { + sc = E_ABORT; + } + } + + // Create a COleObject + if (SUCCEEDED(sc)) + { + _pOleObject = new COleObject(this); + if (NULL == _pOleObject) + { + sc = E_ABORT; + } + } + + // Create a CPersistStorage + if (SUCCEEDED(sc)) + { + _pPersStg = new CPersistStorage(this); + if (NULL == _pPersStg) + { + sc = E_ABORT; + } + } + + if (FAILED(sc)) + { + delete _pDataObject; + delete _pOleObject; + delete _pPersStg; + _pDataObject = NULL; + _pOleObject = NULL; + _pPersStg = NULL; + _ptsaServer = NULL; + _hwnd = NULL; + } + + // Inform controlling server we are a new embedded object + if (SUCCEEDED(sc)) + { + _ptsaServer->IncEmbeddedCount(); + } + + return(sc); +} + + +//+------------------------------------------------------------------- +// Method: CTestEmbed::QueryInterface +// +// Synopsis: IUnknown, IOleObject, IPersist, IPersistStorage supported +// return pointer to the actual object +// +// Parameters: [iid] - Interface ID to return. +// [ppv] - Pointer to pointer to object. +// +// Returns: S_OK if iid is supported, or E_NOINTERFACE if not. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CTestEmbed::QueryInterface(REFIID iid, void FAR * FAR * ppv) +{ + SCODE scRet; + + if (GuidEqual(IID_IUnknown, iid)) + { + *ppv = (IUnknown *)this; + AddRef(); + scRet = S_OK; + } + else + if (GuidEqual(IID_IOleObject, iid)) + { + *ppv = _pOleObject; + AddRef(); + scRet = S_OK; + } + else + if (GuidEqual(IID_IPersist, iid) || GuidEqual(IID_IPersistStorage, iid)) + { + *ppv = _pPersStg; + AddRef(); + scRet = S_OK; + } + else + if (GuidEqual(IID_IDataObject, iid)) + { + *ppv = _pDataObject; + AddRef(); + scRet = S_OK; + } + else + { + *ppv = NULL; + scRet = E_NOINTERFACE; + } + + return(scRet); +} + + +STDMETHODIMP_(ULONG) CTestEmbed::AddRef(void) +{ + return ++_cRef; +} + +STDMETHODIMP_(ULONG) CTestEmbed::Release(void) +{ + ULONG cRefs = --_cRef; + + if (cRefs == 0) + { + delete this; + } + + return cRefs; +} +SCODE CTestEmbed::GetWindow(HWND *phwnd) +{ + if (NULL != phwnd) + { + *phwnd = _hwnd; + return(S_OK); + } + else + { + return(E_ABORT); + } +} diff --git a/private/oleutest/server1/daytona/makefile b/private/oleutest/server1/daytona/makefile new file mode 100644 index 000000000..1d3728d41 --- /dev/null +++ b/private/oleutest/server1/daytona/makefile @@ -0,0 +1,10 @@ +############################################################################ +# +# Copyright (C) 1992, Microsoft Corporation. +# +# All rights reserved. +# +############################################################################ + +!include $(NTMAKEENV)\makefile.def + diff --git a/private/oleutest/server1/daytona/sources b/private/oleutest/server1/daytona/sources new file mode 100644 index 000000000..6f6f53f6b --- /dev/null +++ b/private/oleutest/server1/daytona/sources @@ -0,0 +1,80 @@ +!IF 0 + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + sources. + +Abstract: + + This file specifies the target component being built and the list of + sources files needed to build that component. Also specifies optional + compiler switches and libraries that are unique for the component being + built. + + +Author: + + Donna Liu (DonnaLi) 19-Dec-1993 + +!ENDIF + +MAJORCOMP = cairole +MINORCOMP = com + +# +# This is the name of the target built from the source files specified +# below. The name should include neither the path nor the file extension. +# + +TARGETNAME= testsrv + +# +# This specifies where the target is to be built. A private target of +# type LIBRARY or DYNLINK should go to obj, whereas a public target of +# type LIBRARY or DYNLINK should go to $(BASEDIR)\public\sdk\lib. +# + +TARGETPATH= obj + +# +# This specifies the type of the target, such as PROGRAM, DYNLINK, LIBRARY, +# etc. +# + +TARGETTYPE= PROGRAM + +INCLUDES= ..;..\..\common;..\..\..\ole32\common\daytona;..\..\..\ole32\ih;..\..\..\cinc + +!include ..\..\daytona.inc + +C_DEFINES= \ + $(C_DEFINES) + + +SOURCES= \ + ..\testsrv.rc \ + ..\testsrv.cxx \ + ..\csrvapp.cxx \ + ..\ctestemb.cxx \ + ..\ipersist.cxx \ + ..\ioleobj.cxx \ + ..\idataobj.cxx \ + ..\ctestcf.cxx + +UMTYPE= windows +UMENTRY= winmain +UMAPPL= +UMTEST= +UMLIBS= \ + ..\..\assert\daytona\obj\*\assert.lib \ + $(BASEDIR)\public\sdk\lib\*\ole32.lib \ + $(BASEDIR)\public\sdk\lib\*\gdi32.lib \ + $(BASEDIR)\public\sdk\lib\*\kernel32.lib \ + $(BASEDIR)\public\sdk\lib\*\user32.lib \ + $(BASEDIR)\public\sdk\lib\*\advapi32.lib \ + $(BASEDIR)\public\sdk\lib\*\crtdll.lib \ + $(BASEDIR)\public\sdk\lib\*\uuid.lib + +USE_CRTDLL= 1 diff --git a/private/oleutest/server1/dirs b/private/oleutest/server1/dirs new file mode 100644 index 000000000..1d0b9edbb --- /dev/null +++ b/private/oleutest/server1/dirs @@ -0,0 +1,38 @@ +!IF 0 + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + dirs. + +Abstract: + + This file specifies the subdirectories of the current directory that + contain component makefiles. + + +Author: + + Donna Liu (DonnaLi) 19-Dec-1993 + +!ENDIF + +# +# This is a list of all subdirectories that build required components. +# Each subdirectory name should appear on a line by itself. The build +# follows the order in which the subdirectories are specified. +# + +DIRS= + +# +# This is a list of all subdirectories that build optional components. +# Each subdirectory name should appear on a line by itself. The build +# follows the order in which the subdirectories are specified. +# + +OPTIONAL_DIRS= \ + \ + \ + daytona diff --git a/private/oleutest/server1/idataobj.cxx b/private/oleutest/server1/idataobj.cxx new file mode 100644 index 000000000..0bf409bdb --- /dev/null +++ b/private/oleutest/server1/idataobj.cxx @@ -0,0 +1,306 @@ +//+------------------------------------------------------------------- +// File: idataobj.cxx +// +// Contents: IDataObject methods of CTestEmbed class. +// +// Classes: CTestEmbed - IDataObject implementation +// +// History: 7-Dec-92 DeanE Created +//--------------------------------------------------------------------- +#pragma optimize("",off) +#include <windows.h> +#include <ole2.h> +#include "testsrv.hxx" + + +//+------------------------------------------------------------------- +// Member: CDataObject::CDataObject() +// +// Synopsis: The constructor for CDataObject. +// +// Arguments: None +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +CDataObject::CDataObject(CTestEmbed *pteObject) +{ + _cRef = 1; + _pDAHolder = NULL; + _pteObject = pteObject; +} + + +//+------------------------------------------------------------------- +// Member: CDataObject::~CDataObject() +// +// Synopsis: The destructor for CDataObject. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +CDataObject::~CDataObject() +{ + // _cRef count should be 1 + if (1 != _cRef) + { + // BUGBUG - Log error + // Someone hasn't released one of these - Log error + } + return; +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::QueryInterface +// +// Synopsis: Forward this to the object we're associated with +// +// Parameters: [iid] - Interface ID to return. +// [ppv] - Pointer to pointer to object. +// +// Returns: S_OK if iid is supported, or E_NOINTERFACE if not. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::QueryInterface(REFIID iid, void FAR * FAR *ppv) +{ + return(_pteObject->QueryInterface(iid, ppv)); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::AddRef +// +// Synopsis: Forward this to the object we're associated with +// +// Returns: New reference count. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP_(ULONG) CDataObject::AddRef(void) +{ + ++_cRef; + return(_pteObject->AddRef()); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::Release +// +// Synopsis: Forward this to the object we're associated with +// +// Returns: New reference count. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP_(ULONG) CDataObject::Release(void) +{ + --_cRef; + return(_pteObject->Release()); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::GetData +// +// Synopsis: See spec 2.00.09 p129. Retrieve data for this object +// using the FORMATETC passed. +// +// Parameters: [pformatetcIn] - The format caller wants returned data +// [pmedium] - Returned data +// +// Returns: S_OK, or E_FORMAT if we don't support the format requested +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::GetData( + LPFORMATETC pformatetcIn, + LPSTGMEDIUM pmedium) +{ + // BUGBUG - NYI + return(E_FAIL); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::GetDataHere +// +// Synopsis: See spec 2.00.09 p130. Like GetData, but the pmedium is +// allocated and ready for us to use. +// +// Parameters: [pformatetc] - The format caller wants returned data +// [pmedium] - STGMEDIUM object ready for our use +// +// Returns: S_OK, E_FORMAT +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::GetDataHere( + LPFORMATETC pformatetc, + LPSTGMEDIUM pmedium) +{ + // BUGBUG - NYI + return(E_FAIL); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::QueryGetData +// +// Synopsis: See spec 2.00.09 p130. Answer if the format requested +// would be honored by GetData. +// +// Parameters: [pformatetc] - The format being queried about +// +// Returns: S_OK or S_FALSE +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::QueryGetData(LPFORMATETC pformatetc) +{ + // BUGBUG - NYI + return(E_FAIL); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::GetCanonicalFormatEtc +// +// Synopsis: See spec 2.00.09 p131 +// +// Parameters: [pformatetc] - +// [pformatetcOut] - +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::GetCanonicalFormatEtc( + LPFORMATETC pformatetc, + LPFORMATETC pformatetcOut) + +{ + // BUGBUG - NYI + return(E_FAIL); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::SetData +// +// Synopsis: See spec 2.00.09 p131. +// +// Parameters: [pformatetc] - +// [pmedium] - +// [fRelease] - +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::SetData( + LPFORMATETC pformatetc, + STGMEDIUM FAR *pmedium, + BOOL fRelease) +{ + // BUGBUG - NYI + return(DV_E_CLIPFORMAT); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::EnumFormatEtc +// +// Synopsis: See spec 2.00.09 p131. +// +// Parameters: [dwDirection] - +// [ppenmFormatEtc] - +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::EnumFormatEtc( + DWORD dwDirection, + LPENUMFORMATETC FAR *ppenmFormatEtc) +{ + // BUGBUG - NYI + *ppenmFormatEtc = NULL; + return(E_FAIL); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::DAdvise +// +// Synopsis: See spec 2.00.09 p132 +// +// Parameters: [pFormatetc] - +// [advf] - +// [pAdvSink] - +// [pdwConnection] - +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::DAdvise( + FORMATETC FAR *pFormatetc, + DWORD advf, + LPADVISESINK pAdvSink, + DWORD FAR *pdwConnection) +{ + if (NULL == _pDAHolder) + { + if (S_OK != CreateDataAdviseHolder(&_pDAHolder)) + { + return(E_OUTOFMEMORY); + } + } + + return(_pDAHolder->Advise(this, pFormatetc, advf, pAdvSink, pdwConnection)); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::DUnadvise +// +// Synopsis: See spec 2.00.09 p133 +// +// Parameters: [dwConnection] - +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::DUnadvise(DWORD dwConnection) +{ + if (NULL == _pDAHolder) + { + // Nobody is registered + return(E_INVALIDARG); + } + + return(_pDAHolder->Unadvise(dwConnection)); +} + + +//+------------------------------------------------------------------- +// Method: CDataObject::EnumDAdvise +// +// Synopsis: See spec 2.00.09 p133 +// +// Parameters: [ppenmAdvise] - +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CDataObject::EnumDAdvise(LPENUMSTATDATA FAR *ppenmAdvise) +{ + if (NULL == _pDAHolder) + { + return(E_FAIL); + } + + return(_pDAHolder->EnumAdvise(ppenmAdvise)); +} diff --git a/private/oleutest/server1/ioleobj.cxx b/private/oleutest/server1/ioleobj.cxx new file mode 100644 index 000000000..a26d53c9a --- /dev/null +++ b/private/oleutest/server1/ioleobj.cxx @@ -0,0 +1,629 @@ +//+------------------------------------------------------------------- +// File: ioleobj.cxx +// +// Contents: IOleObject methods of COleObject class. +// +// Classes: COleObject - IOleObject implementation +// +// History: 7-Dec-92 DeanE Created +// 31-Dec-93 ErikGav Chicago port +//--------------------------------------------------------------------- +#pragma optimize("",off) +#include <windows.h> +#include <ole2.h> +#include "testsrv.hxx" + + +//+------------------------------------------------------------------- +// Member: COleObject::COleObject() +// +// Synopsis: The constructor for COleObject. +// +// Arguments: None +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +COleObject::COleObject(CTestEmbed *pteObject) +{ + _cRef = 1; + _pOAHolder = NULL; + _pocs = NULL; + _pteObject = pteObject; + _pmkContainer = NULL; +} + + +//+------------------------------------------------------------------- +// Member: COleObject::~COleObject() +// +// Synopsis: The destructor for COleObject. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +COleObject::~COleObject() +{ + // _cRef should be 1 + if (1 != _cRef) + { + // BUGBUG - Log error - someone hasn't released + } + + if (_pocs != NULL) + { + _pocs->Release(); + } + + if (_pmkContainer != NULL) + { + _pmkContainer->Release(); + } + +} + + +//+------------------------------------------------------------------- +// Method: COleObject::QueryInterface +// +// Synopsis: Forward this to the object we're associated with +// +// Parameters: [iid] - Interface ID to return. +// [ppv] - Pointer to pointer to object. +// +// Returns: S_OK if iid is supported, or E_NOINTERFACE if not. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::QueryInterface(REFIID iid, void FAR * FAR *ppv) +{ + return(_pteObject->QueryInterface(iid, ppv)); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::AddRef +// +// Synopsis: Forward this to the object we're associated with +// +// Returns: New reference count. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP_(ULONG) COleObject::AddRef(void) +{ + ++_cRef; + return(_pteObject->AddRef()); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::Release +// +// Synopsis: Forward this to the object we're associated with +// +// Returns: New reference count. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP_(ULONG) COleObject::Release(void) +{ + --_cRef; + return(_pteObject->Release()); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::SetClientSite +// +// Synopsis: Save the IOleClientSite pointer passed - it's this +// object's client site object. +// +// Parameters: [pClientSite] - Pointer to the new client site object. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::SetClientSite(LPOLECLIENTSITE pClientSite) +{ + if (_pocs != NULL) + { + _pocs->Release(); + } + + _pocs = pClientSite; + + if (pClientSite) + { + _pocs->AddRef(); + } + + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::GetClientSite +// +// Synopsis: Return this objects current client site - NULL indicates +// it hasn't been set yet. +// +// Parameters: [ppClientSite] - Save current client site pointer here. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::GetClientSite(LPOLECLIENTSITE FAR *ppClientSite) +{ + *ppClientSite = _pocs; + _pocs->AddRef(); + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::SetHostNames +// +// Synopsis: See spec 2.00.09 p99. Returns names the caller can use +// to display our object name (in window titles and such). +// +// Parameters: [szContainerApp] - Name of container application. +// [szContainerObj] - Name of this object. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::SetHostNames( + LPCWSTR szContainerApp, + LPCWSTR szContainerObj) +{ + szContainerApp = L"Test Server"; + szContainerObj = L"Test Server:Test Object"; + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::Close +// +// Synopsis: See spec 2.00.09 p104. Short story is: if fMerelyHide, +// turn off the UI of this object, else return to the +// "loaded" state, which for us means to shut down (since we +// don't do any caching). +// +// Parameters: [dwSaveOption] - ??? +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +// +// Notes: BUGBUG - what if we have multiple instances? Do we +// return the server app to the loaded state or do we +// return this object to the loaded state? +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::Close(DWORD dwSaveOption) +{ + // BUGBUG - NYI + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::SetMoniker +// +// Synopsis: See spec 2.00.09 p99. The moniker for this object +// (or it's container) has been changed to that passed +// in. Take appropriate actions (de-register old object +// and register new, inform contained objects, etc). +// +// Parameters: [dwWhichMoniker] - Moniker type being sent. +// [pmk] - The new moniker. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::SetMoniker(DWORD dwWhichMoniker, LPMONIKER pmk) +{ + if (_pmkContainer) + { + _pmkContainer->Release(); + + } + + _pmkContainer = pmk; + + pmk->AddRef(); + + // Set moniker in container + IOleObject *pobj; + + HRESULT hresult = _pocs->QueryInterface(IID_IOleObject, (void **) &pobj); + + pobj->SetMoniker(dwWhichMoniker, pmk); + + pobj->Release(); + + return S_OK; +} + + +//+------------------------------------------------------------------- +// Method: COleObject::GetMoniker +// +// Synopsis: See spec 2.00.09 p100. Return either this objects +// container moniker, this objects relative moniker, or +// this objects full moniker. +// +// Parameters: [dwAssign] - Condition to get moniker. +// [dwWhichMoniker] - Kind of moniker being requested. +// [ppmk] - Return moniker here. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::GetMoniker( + DWORD dwAssign, + DWORD dwWhichMoniker, + LPMONIKER FAR *ppmk) +{ + *ppmk = _pmkContainer; + _pmkContainer->AddRef(); + return S_OK; +} + + +//+------------------------------------------------------------------- +// Method: COleObject::InitFromData +// +// Synopsis: See spec 2.00.09 p100. Initialize this object from +// the format passed in. +// +// Parameters: [pDataObject] - IDataObject providing data. +// [fCreation] - TRUE if this is the initial creation. +// [dwReserved] - Ignored. +// +// Returns: S_OK if we attempt to initialize, S_FALSE if we don't +// want to. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::InitFromData( + LPDATAOBJECT pDataObject, + BOOL fCreation, + DWORD dwReserved) +{ + // BUGBUG - NYI + return(S_FALSE); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::GetClipboardData +// +// Synopsis: See spec 2.00.09 p101. Return clipboard object that would +// be created if Edit/Copy were done to this item. +// +// Parameters: [dwReserved] - Ignored. +// [ppDataObject] - IDataObject return locale. +// +// Returns: S_OK or ??? +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::GetClipboardData( + DWORD dwReserved, + LPDATAOBJECT FAR *ppDataObject) +{ + // BUGBUG - NYI + *ppDataObject = NULL; + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::DoVerb +// +// Synopsis: See spec 2.00.09 p101. Execute the verb passed in. +// +// Parameters: [iVerb] - Verb being requested. +// [pMsg] - Message that triggered the request. +// [pActiveSite] - IOleClientSite for this object. +// [lReserved] - Ignored. +// +// Returns: S_OK, or other ones specified but not defined yet... +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::DoVerb( + LONG iVerb, + LPMSG pMsg, + LPOLECLIENTSITE pActiveSite, + LONG lReserved, + HWND hwndParent, + LPCRECT lprcPosRect) +{ + // HWND hwndObj; + + if (OLEIVERB_SHOW == iVerb) + { + // BUGBUG - NYI + // Display the object (we're not in-place yet) + // PostMessage(g_hwndMain, WM_REPORT, MB_SHOWVERB, 0); + // PostMessage(0xFFFF, WM_REPORT, MB_SHOWVERB, 0); + // MessageBox(g_hwndMain, L"Received OLEIVERB_SHOW", L"OLE Server", MB_ICONINFORMATION | MB_OK); + + // Get hwndObj + //_pteObject->GetWindow(&hwndObj); + //MessageBox(hwndObj, L"Received OLEIVERB_SHOW", L"OLE Server", MB_ICONINFORMATION | MB_OK); + } + else + { + // Return alternate error code? + } + + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::EnumVerbs +// +// Synopsis: See spec 2.00.09 p103. Enumerate all the verbs available +// on this object in increasing numerical order. +// +// Parameters: [ppenmOleVerb] - Enumeration object return locale. +// +// Returns: S_OK or ??? +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::EnumVerbs(IEnumOLEVERB FAR* FAR *ppenmOleVerb) +{ + // BUGBUG - NYI + *ppenmOleVerb = NULL; + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::Update +// +// Synopsis: See spec 2.00.09 p105. Ensure any data or view caches +// maintained inside the object are up to date. +// +// Parameters: None +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::Update() +{ + // We don't use any caches, so we don't have to do anything + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::IsUpToDate +// +// Synopsis: See spec 2.00.09 p105. Check to see if this object is +// up to date - including embedded children, etc. +// +// Parameters: None +// +// Returns: S_OK, S_FALSE, or ??? +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::IsUpToDate() +{ + // We should always be up to date as we don't have any caches + // or children or links + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::GetUserClassID +// +// Synopsis: I have little idea what this does. It's not in the +// spec 2.00.09. +// +// Parameters: [dwFormOfType] - +// [pszUserType] - +// +// Returns: S_OK? +// +// History: 16-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::GetUserClassID( + CLSID FAR *pClsid) +{ + // BUGBUG - NYI + return(E_FAIL); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::GetUserType +// +// Synopsis: I have little idea what this does. It's not in the +// spec 2.00.09. +// +// Parameters: [dwFormOfType] - +// [pszUserType] - +// +// Returns: S_OK? +// +// History: 16-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::GetUserType( + DWORD dwFormOfType, + LPWSTR FAR *pszUserType) +{ + // BUGBUG - NYI + return(E_FAIL); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::SetExtent +// +// Synopsis: See spec 2.00.09 p106. Set the rectangular extent of +// this object. Container will call us with the size +// it will give us; we must fit accordingly. +// +// Parameters: [dwDrawAspect] - DVASPECT specified for this object. +// [lpsizel] - Extent structure. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::SetExtent(DWORD dwDrawAspect, LPSIZEL lpsizel) +{ + // BUGBUG - NYI + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::GetExtent +// +// Synopsis: See spec 2.00.09 p106. Size of the object given in the +// the last SetExtent call is returned. If SetExtent has +// not been called, the natural size of the object is +// returned. +// +// Parameters: [dwDrawAspect] - DVASPECT specified for this object. +// [lpsizel] - Extent structure to set. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::GetExtent(DWORD dwDrawAspect, LPSIZEL lpsizel) +{ + // BUGBUG - NYI + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::Advise +// +// Synopsis: See spec 2.00.09 p121. Set up an advisory connection +// between this object and an advisory sink; when certain +// events happen (birthdays?) this sink should be informed +// by this object. Use the OleAdviseHolder object as a +// helper (see p122). +// +// Parameters: [pAdvSink] - Sink that should be informed of changes. +// [pdwConnection] - Pass advisory token returned so our +// caller can shut down the link. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::Advise( + IAdviseSink FAR *pAdvSink, + DWORD FAR *pdwConnection) +{ +// if (NULL == _pOAHolder) +// { +// if (S_OK != CreateOleAdviseHolder(&_pOAHolder)) +// { +// return(E_OUTOFMEMORY); +// } +// } +// +// return(_pOAHolder->Advise(pAdvSink, pdwConnection)); + return S_OK; +} + + +//+------------------------------------------------------------------- +// Method: COleObject::Unadvise +// +// Synopsis: See spec 2.00.09 p121. Tear down an advisory connection +// set up previously. +// +// Parameters: [dwConnection] - Connection established earlier. +// +// Returns: S_OK or ??? +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::Unadvise(DWORD dwConnection) +{ + if (NULL == _pOAHolder) + { + // No one is registered - see ellipswt.cpp for this + return(E_INVALIDARG); + } + + return(_pOAHolder->Unadvise(dwConnection)); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::EnumAdvise +// +// Synopsis: See spec 2.00.09 p122. Enumerate the advisory connections +// currently attached to this object. +// +// Parameters: [ppenmAdvise] - Enumeration object to return. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::EnumAdvise(LPENUMSTATDATA FAR *ppenmAdvise) +{ + if (NULL == _pOAHolder) + { + return(E_FAIL); + } + return(_pOAHolder->EnumAdvise(ppenmAdvise)); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::GetMiscStatus +// +// Synopsis: I have little idea what this does. It's not in the +// spec 2.00.09. +// +// Returns: S_OK? +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::GetMiscStatus( + DWORD dwAspect, + DWORD FAR *pdwStatus) +{ + // BUGBUG - NYI + return(E_FAIL); +} + + +//+------------------------------------------------------------------- +// Method: COleObject::SetColorScheme +// +// Synopsis: I have little idea what this does. It's not in the +// spec 2.00.09. +// +// Returns: S_OK? +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP COleObject::SetColorScheme(LPLOGPALETTE lpLogpal) +{ + // BUGBUG - NYI + return(S_OK); +} diff --git a/private/oleutest/server1/ipersist.cxx b/private/oleutest/server1/ipersist.cxx new file mode 100644 index 000000000..4928a1e01 --- /dev/null +++ b/private/oleutest/server1/ipersist.cxx @@ -0,0 +1,251 @@ +//+------------------------------------------------------------------- +// File: ipersist.cxx +// +// Contents: IPersist and IPersistStorage methods of CPersistStorage class. +// +// Classes: CPersistStorage - IPersist, IPersistStorage implementations +// +// History: 7-Dec-92 DeanE Created +//--------------------------------------------------------------------- +#pragma optimize("",off) +#include <windows.h> +#include <ole2.h> +#include "testsrv.hxx" + + +//+------------------------------------------------------------------- +// Member: CPersistStorage::CPersistStorage() +// +// Synopsis: The constructor for CPersistStorage. +// +// Arguments: None +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +CPersistStorage::CPersistStorage(CTestEmbed *pteObject) +{ + _cRef = 1; + _pteObject = pteObject; + _fDirty = FALSE; +} + + +//+------------------------------------------------------------------- +// Member: CPersistStorage::~CPersistStorage() +// +// Synopsis: The destructor for CPersistStorage. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +CPersistStorage::~CPersistStorage() +{ + // _cRef should be 1 + if (1 != _cRef) + { + // BUGBUG - Log error, someone hasn't released + } + return; +} + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::QueryInterface +// +// Synopsis: Forward this to the object we're associated with +// +// Parameters: [iid] - Interface ID to return. +// [ppv] - Pointer to pointer to object. +// +// Returns: S_OK if iid is supported, or E_NOINTERFACE if not. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CPersistStorage::QueryInterface(REFIID iid, void FAR * FAR *ppv) +{ + return(_pteObject->QueryInterface(iid, ppv)); +} + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::AddRef +// +// Synopsis: Forward this to the object we're associated with +// +// Returns: New reference count. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP_(ULONG) CPersistStorage::AddRef(void) +{ + ++_cRef; + return(_pteObject->AddRef()); +} + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::Release +// +// Synopsis: Forward this to the object we're associated with +// +// Returns: New reference count. +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP_(ULONG) CPersistStorage::Release(void) +{ + --_cRef; + return(_pteObject->Release()); +} + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::GetClassId +// +// Synopsis: See spec 2.00.09 p197. Answer the Class ID of this +// object. +// +// Parameters: [pClassId] - +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CPersistStorage::GetClassID(LPCLSID pClassId) +{ + if (NULL != pClassId) + { + *pClassId = CLSID_TestEmbed; + } + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::IsDirty +// +// Synopsis: See spec 2.00.09 p200. Return S_OK if the object needs +// to be saved in order to avoid data loss, or S_FALSE +// if not. +// +// Parameters: None +// +// Returns: S_OK or S_FALSE +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CPersistStorage::IsDirty() +{ + // BUGBUG - NYI + // Because we are NYI, just return S_FALSE + return(S_FALSE); +} + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::InitNew +// +// Synopsis: See spec 2.00.09 p197. This method provides a way +// for a container to provide persistent storage to this +// object. Call AddRef on the pStg passed if we do save +// it. +// +// Parameters: [pStg] - IStorage instance this object can use. +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CPersistStorage::InitNew(LPSTORAGE pStg) +{ + // BUGBUG - NYI + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::Load +// +// Synopsis: See spec 2.00.09 p200. Called by handler to put this +// object into the running state. Object should use the +// pStg passed to "initialize" itself. We can hold onto +// this pStg, but when ::Save is called, this can be +// a different IStorage. +// +// Parameters: [pStg] - IStorage to initialize object from. +// +// Returns: S_OK? +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CPersistStorage::Load(LPSTORAGE pStg) +{ + // BUGBUG - NYI + // Initialize the object here, though, just as if we had obtained + // data from an IStorage + return(S_OK); +} + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::Save +// +// Synopsis: See spec 2.00.09 p197. Save the data in the IStorage +// passed. Ignore flags for now. +// +// Parameters: [pStgSave] - Save data in here. +// [fSameAsLoad] - Indicates this object is the same one +// that was initially started. +// [fRemember] - Only matters if fSameAsLoad is FALSE. +// +// Returns: STG_E_MEDIUMFULL - why??? +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CPersistStorage::Save( + LPSTORAGE pStgSave, + BOOL fSameAsLoad) +{ + // BUGBUG - NYI + return(STG_E_MEDIUMFULL); +} + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::SaveCompleted +// +// Synopsis: See spec 2.00.09 p198. Used only in certain circumstances. +// +// Parameters: [pStgSaved] - +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CPersistStorage::SaveCompleted(LPSTORAGE pStgSaved) +{ + // BUGBUG - NYI + // We don't have to worry about this unless we allow a "Save As" + // operation + return(S_OK); +} + + + +//+------------------------------------------------------------------- +// Method: CPersistStorage::HandsOffStorage +// +// Synopsis: See spec 2.00.09 p198. Used only in certain circumstances. +// +// Parameters: [pStgSaved] - +// +// Returns: S_OK +// +// History: 7-Dec-92 DeanE Created +//-------------------------------------------------------------------- +STDMETHODIMP CPersistStorage::HandsOffStorage(void) +{ + // BUGBUG - NYI + // We don't have to worry about this unless we allow a "Save As" + // operation + return(S_OK); +} diff --git a/private/oleutest/server1/testsrv.cxx b/private/oleutest/server1/testsrv.cxx new file mode 100644 index 000000000..6c1a2181e --- /dev/null +++ b/private/oleutest/server1/testsrv.cxx @@ -0,0 +1,204 @@ +//+------------------------------------------------------------------- +// File: testsrv.cxx +// +// Contents: +// +// Classes: CBasicSrvCF - IUnknown IClassFactory +// CBasicSrv - IUnknown IPersist IPersistFile IParseDisplayName +// +// Notes: This code is written based on OLE2.0 code. Therefore +// all error codes, defines etc are OLE style rather than Cairo +// +// History: 24-Nov-92 DeanE Created +// 31-Dec-93 ErikGav Chicago port +//--------------------------------------------------------------------- +#pragma optimize("",off) +#include <windows.h> +#include <ole2.h> +#include "testsrv.hxx" +#include <stdio.h> + +// BUGBUG - memory allocation hacks need these so new and delete don't +// break us +// +#include <malloc.h> +#include <dos.h> + +#define IDM_DEBUG 0x100 + +extern "C" LRESULT FAR PASCAL MainWndProc(HWND, UINT, WPARAM, LPARAM); +void ReportMessage(HWND, WORD); + +// This is global because we're still in $%E#$#K 16-bit world +HWND g_hwndMain = NULL; + +// Note constructor cannot fail +CTestServerApp tsaMain; + + +//+-------------------------------------------------------------- +// Function: WinMain +// +// Synopsis: Initializes application and controls message pump. +// +// Returns: Exits with exit code 0 if success, non-zero otherwise +// +// History: 25-Nov-92 DeanE Created +//--------------------------------------------------------------- +int PASCAL WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdline, + int nCmdShow) +{ + static TCHAR szAppName[] = TEXT("OleServer"); + MSG msg; + WNDCLASS wndclass; + + if (!hPrevInstance) + { + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = MainWndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = hInstance; + wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(125)); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = szAppName; + + if (0==RegisterClass(&wndclass)) + { + // Error! Clean up and exit + return(LOG_ABORT); + } + } + + g_hwndMain = CreateWindow( + szAppName, + TEXT("OLE Server"), + WS_OVERLAPPEDWINDOW | WS_VSCROLL, + GetSystemMetrics(SM_CXSCREEN)/12, // Init X pos + GetSystemMetrics(SM_CYSCREEN)/12, // Init Y pos + GetSystemMetrics(SM_CXSCREEN)*2/3, // width + GetSystemMetrics(SM_CYSCREEN)*2/3, // height + NULL, + NULL, + hInstance, + NULL); + + if (NULL==g_hwndMain) + { + // Error! Clean up and exit + return(LOG_ABORT); + } + + // Add debug option to system menu + HMENU hmenu = GetSystemMenu(g_hwndMain, FALSE); + + AppendMenu(hmenu, MF_SEPARATOR, 0, NULL); + AppendMenu(hmenu, MF_STRING | MF_ENABLED, IDM_DEBUG, TEXT("Debug")); + + + // Initialize Application + if (S_OK != tsaMain.InitApp(lpszCmdline)) + { + tsaMain.CloseApp(); + return(LOG_ABORT); + } + + if (tsaMain.GetEmbeddedFlag()) + { + // We're running as an embedded app + // Don't show the main window unless we're instructed to do so + // BUGBUG - In-place editing is NYI + ShowWindow(g_hwndMain, SW_SHOWMINIMIZED); + } + else + { + // We are not running as an embedded app - show the main window + ShowWindow(g_hwndMain, nCmdShow); + } + + UpdateWindow(g_hwndMain); + + + // message loop + while (GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + // Clean up and exit + // BUGBUG - check return code? + tsaMain.CloseApp(); + + return(0); +} + + +//+-------------------------------------------------------------- +// Function: MainWndProc +// +// Synopsis: Callback for the server window +// +// Returns: Varies dependent on message received. +// +// History: 25-Nov-92 DeanE Created +//--------------------------------------------------------------- +extern "C" LRESULT FAR PASCAL MainWndProc( + HWND hwnd, + UINT wMsg, + WPARAM wParam, + LPARAM lParam) +{ + switch(wMsg) + { + case WM_DESTROY: + PostQuitMessage(0); + return(0); + + case WM_USER: + DestroyWindow(hwnd); + return 0; + + case WM_SYSCOMMAND: + + if (wParam == IDM_DEBUG) + { + // Request for a debug breakpoint! + DebugBreak(); + } + + default: + break; + } + + return(DefWindowProc(hwnd, wMsg, wParam, lParam)); +} + + +void ReportMessage(HWND hwnd, WORD wParam) +{ + TCHAR szBuffer[256]; + szBuffer[0] = '\0'; + + switch (wParam) + { + case MB_SHOWVERB: + lstrcpy(szBuffer, TEXT("OLEIVERB_SHOW Received")); + break; + + case MB_PRIMVERB: + lstrcpy(szBuffer, TEXT("OLEIVERB_PRIMARY Received")); + break; + + default: + lstrcpy(szBuffer, TEXT("Unrecognized ReportMessage code")); + break; + } + + MessageBox(hwnd, szBuffer, TEXT("OLE Server"), MB_ICONINFORMATION | MB_OK); +} diff --git a/private/oleutest/server1/testsrv.hxx b/private/oleutest/server1/testsrv.hxx new file mode 100644 index 000000000..a47aef4f2 --- /dev/null +++ b/private/oleutest/server1/testsrv.hxx @@ -0,0 +1,386 @@ +//+------------------------------------------------------------------- +// File: testsrv.hxx +// +// Contents: CTestEmbedCF and CTestEmbed object declarations, other +// miscellaneous tidbits. +// +// History: 24-Nov-92 DeanE Created +// 31-Dec-93 ErikGav Chicago port +//--------------------------------------------------------------------- + +#ifndef __TESTSRV_HXX__ +#define __TESTSRV_HXX__ + +#include <com.hxx> + +#define LOG_ABORT -1 +#define LOG_PASS 1 +#define LOG_FAIL 0 + +// Application Window messages +#define WM_RUNTEST (WM_USER + 1) +#define WM_REPORT (WM_USER + 2) + + +// WM_REPORT wParam codes +#define MB_SHOWVERB 0x0001 +#define MB_PRIMVERB 0x0002 + +//+--------------------------------------------------------------------------- +// +// Function: operator new, public +// +// Synopsis: Global operator new which uses CoTaskMemAlloc +// +// Arguments: [size] -- Size of the memory to allocate. +// +// Returns: A pointer to the allocated memory. Is *NOT* initialized to 0! +// +//---------------------------------------------------------------------------- + +inline void* _CRTAPI1 +operator new (size_t size) +{ + return(CoTaskMemAlloc(size)); +} + +//+------------------------------------------------------------------------- +// +// Function: operator delete +// +// Synopsis: Free a block of memory using CoTaskMemFree +// +// Arguments: [lpv] - block to free. +// +//-------------------------------------------------------------------------- + +inline void _CRTAPI1 operator delete(void FAR* lpv) +{ + CoTaskMemFree(lpv); +} + +// Global variables +extern HWND g_hwndMain; + + +// Forward declarations +class FAR CDataObject; +class FAR CPersistStorage; +class FAR COleObject; +class FAR CTestEmbedCF; + + +//+------------------------------------------------------------------- +// Class: CTestServerApp +// +// Synopsis: Class that holds application-wide data and methods +// +// Methods: InitApp +// CloseApp +// GetEmbeddedFlag +// +// History: 17-Dec-92 DeanE Created +//-------------------------------------------------------------------- +class FAR CTestServerApp +{ +public: + +// Constructor/Destructor + CTestServerApp(); + ~CTestServerApp(); + + SCODE InitApp (LPSTR lpszCmdline); + SCODE CloseApp (void); + BOOL GetEmbeddedFlag (void); + ULONG IncEmbeddedCount(void); + ULONG DecEmbeddedCount(void); + +private: + IClassFactory *_pteClassFactory; + ULONG _cEmbeddedObjs; // Count of embedded objects this server + // is controlling now + DWORD _dwRegId; // OLE registration ID + BOOL _fRegistered; // TRUE if srv was registered w/OLE + BOOL _fInitialized; // TRUE if OleInitialize was OK + BOOL _fEmbedded; // TRUE if OLE started us at the request + // of an embedded obj in a container app +}; + + +//+------------------------------------------------------------------- +// Class: CTestEmbedCF +// +// Synopsis: Class Factory for CTestEmbed object type +// +// Methods: QueryInterface - IUnknown +// AddRef - IUnknown +// Release - IUnknown +// CreateInstance - IClassFactory +// LockServer - IClassFactory +// +// History: 24-Nov-92 DeanE Created +//-------------------------------------------------------------------- +class CTestEmbedCF : public IClassFactory +{ +public: + +// Constructor/Destructor + CTestEmbedCF(CTestServerApp *ptsaServer); + ~CTestEmbedCF(); + static IClassFactory FAR *Create(CTestServerApp *ptsaServer); + +// IUnknown + STDMETHODIMP QueryInterface (REFIID iid, void FAR * FAR *ppv); + STDMETHODIMP_(ULONG) AddRef (void); + STDMETHODIMP_(ULONG) Release (void); + +// IClassFactory + STDMETHODIMP CreateInstance (IUnknown FAR *pUnkOuter, + REFIID iidInterface, + void FAR * FAR *ppv); + STDMETHODIMP LockServer (BOOL fLock); + +private: + + ULONG _cRef; // Reference count on this object + + CTestServerApp *_ptsaServer; // Controlling server app +}; + + +//+------------------------------------------------------------------- +// Class: CTestEmbed +// +// Synopsis: CTestEmbed (one instance per object) +// +// Methods: QueryInterface IUnknown +// AddRef IUnknown +// Release IUnknown +// InitObject +// +// History: 24-Nov-92 DeanE Created +//-------------------------------------------------------------------- +class CTestEmbed : public IUnknown +{ +public: +// Constructor/Destructor + CTestEmbed(); + ~CTestEmbed(); + +// IUnknown + STDMETHODIMP QueryInterface(REFIID iid, void FAR * FAR *ppv); + STDMETHODIMP_(ULONG) AddRef (void); + STDMETHODIMP_(ULONG) Release (void); + + SCODE InitObject (CTestServerApp *ptsaServer, HWND hwnd); + SCODE GetWindow (HWND *phwnd); + +private: + + ULONG _cRef; // Reference counter + CTestServerApp *_ptsaServer; // Server "holding" this object + CDataObject *_pDataObject; // Points to object's IDataObject + COleObject *_pOleObject; // Points to object's IOleObject + CPersistStorage *_pPersStg; // Points to object's IPersistStorage + HWND _hwnd; // Window handle for this object +}; + + +//+------------------------------------------------------------------- +// Class: CDataObject +// +// Synopsis: Test class CDataObject +// +// Methods: QueryInterface IUnknown +// AddRef IUnknown +// Release IUnknown +// GetData IDataObject +// GetDataHere IDataObject +// QueryGetData IDataObject +// GetCanonicalFormatEtc IDataObject +// SetData IDataObject +// EnumFormatEtc IDataObject +// DAdvise IDataObject +// DUnadvise IDataObject +// EnumDAdvise IDataObject +// +// History: 24-Nov-92 DeanE Created +//-------------------------------------------------------------------- +class FAR CDataObject : public IDataObject +{ +public: +// Constructor/Destructor + CDataObject(CTestEmbed *pteObject); + ~CDataObject(); + +// IUnknown - Everyone inherits from this + STDMETHODIMP QueryInterface(REFIID iid, void FAR * FAR *ppv); + STDMETHODIMP_(ULONG) AddRef (void); + STDMETHODIMP_(ULONG) Release (void); + +// IDataObject + STDMETHODIMP GetData (LPFORMATETC pformatetcIn, + LPSTGMEDIUM pmedium); + STDMETHODIMP GetDataHere (LPFORMATETC pformatetc, + LPSTGMEDIUM pmedium); + STDMETHODIMP QueryGetData (LPFORMATETC pformatetc); + STDMETHODIMP GetCanonicalFormatEtc( + LPFORMATETC pformatetc, + LPFORMATETC pformatetcOut); + STDMETHODIMP SetData (LPFORMATETC pformatetc, + STGMEDIUM FAR *pmedium, + BOOL fRelease); + STDMETHODIMP EnumFormatEtc (DWORD dwDirection, + LPENUMFORMATETC FAR *ppenmFormatEtc); + STDMETHODIMP DAdvise (FORMATETC FAR *pFormatetc, + DWORD advf, + LPADVISESINK pAdvSink, + DWORD FAR *pdwConnection); + STDMETHODIMP DUnadvise (DWORD dwConnection); + STDMETHODIMP EnumDAdvise (LPENUMSTATDATA FAR *ppenmAdvise); + +private: + ULONG _cRef; // Reference count + IDataAdviseHolder FAR *_pDAHolder; // Advise Holder + CTestEmbed *_pteObject; // Object we're associated with +}; + + +//+------------------------------------------------------------------- +// Class: COleObject +// +// Synopsis: COleObject implements the IOleObject interface for OLE +// objects within the server. There will be one instantiation +// per OLE object. +// +// Methods: QueryInterface IUnknown +// AddRef IUnknown +// Release IUnknown +// SetClientSite IOleObject +// GetClientSite IOleObject +// SetHostNames IOleObject +// Close IOleObject +// SetMoniker IOleObject +// GetMoniker IOleObject +// InitFromData IOleObject +// GetClipboardData IOleObject +// DoVerb IOleObject +// EnumVerbs IOleObject +// Update IOleObject +// IsUpToDate IOleObject +// GetUserType IOleObject +// SetExtent IOleObject +// GetExtent IOleObject +// Advise IOleObject +// Unadvise IOleObject +// EnumAdvise IOleObject +// GetMiscStatus IOleObject +// SetColorScheme IOleObject +// +// History: 17-Dec-92 DeanE Created +//-------------------------------------------------------------------- +class FAR COleObject : public IOleObject +{ +public: +// Constructor/Destructor + COleObject(CTestEmbed *pteObject); + ~COleObject(); + +// IUnknown + STDMETHODIMP QueryInterface(REFIID iid, void FAR * FAR *ppv); + STDMETHODIMP_(ULONG) AddRef (void); + STDMETHODIMP_(ULONG) Release (void); + +// IOleObject + STDMETHODIMP SetClientSite (LPOLECLIENTSITE pClientSite); + STDMETHODIMP GetClientSite (LPOLECLIENTSITE FAR *ppClientSite); + STDMETHODIMP SetHostNames (LPCWSTR szContainerApp, LPCWSTR szContainerObj); + STDMETHODIMP Close (DWORD dwSaveOption); + STDMETHODIMP SetMoniker (DWORD dwWhichMoniker, LPMONIKER pmk); + STDMETHODIMP GetMoniker (DWORD dwAssign, + DWORD dwWhichMoniker, + LPMONIKER FAR *ppmk); + STDMETHODIMP InitFromData (LPDATAOBJECT pDataObject, + BOOL fCreation, + DWORD dwReserved); + STDMETHODIMP GetClipboardData( + DWORD dwReserved, + LPDATAOBJECT FAR *ppDataObject); + STDMETHODIMP DoVerb (LONG iVerb, + LPMSG pMsg, + LPOLECLIENTSITE pActiveSite, + LONG lReserved, + HWND hwndParent, + LPCRECT lprcPosRect); + STDMETHODIMP EnumVerbs (IEnumOLEVERB FAR* FAR* ppenmOleVerb); + STDMETHODIMP Update (void); + STDMETHODIMP IsUpToDate (void); + STDMETHODIMP GetUserClassID(CLSID FAR* pClsid); + STDMETHODIMP GetUserType (DWORD dwFormOfType, LPWSTR FAR *pszUserType); + STDMETHODIMP SetExtent (DWORD dwDrawAspect, LPSIZEL lpsizel); + STDMETHODIMP GetExtent (DWORD dwDrawAspect, LPSIZEL lpsizel); + STDMETHODIMP Advise (IAdviseSink FAR *pAdvSink, + DWORD FAR *pdwConnection); + STDMETHODIMP Unadvise (DWORD dwConnection); + STDMETHODIMP EnumAdvise (LPENUMSTATDATA FAR *ppenmAdvise); + STDMETHODIMP GetMiscStatus (DWORD dwAspect, DWORD FAR *pdwStatus); + STDMETHODIMP SetColorScheme(LPLOGPALETTE lpLogpal); + +private: + ULONG _cRef; // Reference count + IOleAdviseHolder FAR *_pOAHolder; // Advise Holder + IOleClientSite FAR *_pocs; // This objects client site + CTestEmbed *_pteObject; // Object we're associated with + IMoniker * _pmkContainer; +}; + + +//+------------------------------------------------------------------- +// Class: CPersistStorage +// +// Synopsis: Test class CPersistStorage +// +// Methods: QueryInterface IUnknown +// AddRef IUnknown +// Release IUnknown +// GetClassId IPersist +// IsDirty IPersistStorage +// InitNew IPersistStorage +// Load IPersistStorage +// Save IPersistStorage +// SaveCompleted IPersistStorage +// +// History: 24-Nov-92 DeanE Created +//-------------------------------------------------------------------- +class FAR CPersistStorage : public IPersistStorage +{ +public: +// Constructor/Destructor + CPersistStorage(CTestEmbed *pteObject); + ~CPersistStorage(); + +// IUnknown - Everyone inherits from this + STDMETHODIMP QueryInterface(REFIID iid, void FAR * FAR *ppv); + STDMETHODIMP_(ULONG) AddRef (void); + STDMETHODIMP_(ULONG) Release (void); + +// IPersist - IPersistStorage inherits from this + STDMETHODIMP GetClassID (LPCLSID pClassId); + +// IPersistStorage + STDMETHODIMP IsDirty (void); + STDMETHODIMP InitNew (LPSTORAGE pStg); + STDMETHODIMP Load (LPSTORAGE pStg); + STDMETHODIMP Save (LPSTORAGE pStgSave, + BOOL fSameAsLoad); + STDMETHODIMP SaveCompleted (LPSTORAGE pStgSaved); + STDMETHODIMP HandsOffStorage (void); + +private: + ULONG _cRef; // Reference count + CTestEmbed *_pteObject; // Object we're associated with + BOOL _fDirty; // TRUE if object is dirty +}; + + +#endif // __TESTSRV_HXX__ diff --git a/private/oleutest/server1/testsrv.ico b/private/oleutest/server1/testsrv.ico Binary files differnew file mode 100644 index 000000000..05dac99c1 --- /dev/null +++ b/private/oleutest/server1/testsrv.ico diff --git a/private/oleutest/server1/testsrv.rc b/private/oleutest/server1/testsrv.rc new file mode 100644 index 000000000..51681d8b2 --- /dev/null +++ b/private/oleutest/server1/testsrv.rc @@ -0,0 +1,3 @@ +#include <windows.h> + +125 ICON testsrv.ico |