home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / wincom / dllcom / public / dllcom.h next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.4 KB  |  97 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef __DllCommon_H
  20. #define __DllCommon_H
  21.  
  22. //  Common dll code to be compiled to library form, and then
  23. //      used as a framework by other windows dlls which support
  24. //      both 16 and 32 bits through a COM interface.
  25.  
  26. #include "dlltypes.h"
  27. #include "dlldbg.h"
  28. #include "dlliface.h"
  29. #include "dllmem.h"
  30. #include "dlltask.h"
  31. #include "dllref.h"
  32. #include "dllobj.h"
  33. #include "dllutil.h"
  34.  
  35. //  End consumer must derive from this class and implement the
  36. //      abstract/virtual interfaces.
  37. //  Please note that a CComDll derived class will self destruct
  38. //      once it detects that no more instance data is at hand (no
  39. //      CComClass instances for this CComDll are in existence).
  40. class CComDll : public IUnknown  {
  41. private:
  42.     CProcessEntry *m_pEntry;
  43. public:
  44.     CComDll();
  45.     virtual ~CComDll();
  46.  
  47.     //  Had to break down and track the module for resources and
  48.     //      path resolution situations.
  49.     //  Static is OK, as on 16 bits, the DLL will continue to
  50.     //      have the same module handle no matter how many
  51.     //      different EXEs are looking at it.
  52. public:
  53.     static HINSTANCE m_hInstance;
  54.     static HINSTANCE GetInstanceHandle();
  55.  
  56.     //  Reference counting is done on a per COM object basis in
  57.     //      the instance data.
  58.     //  You must derive your COM related classes from
  59.     //      CComClass as they know how to properly utilize
  60.     //      the following functions of the CComDll instance.
  61. private:
  62.     DWORD m_ulCount;
  63. public:
  64.     STDMETHODIMP QueryInterface(REFIID iid, void **ppObj);
  65.     STDMETHODIMP_(DWORD) AddRef();
  66.     STDMETHODIMP_(DWORD) Release();
  67.  
  68. public:
  69.     //  Provide way to get the module name.
  70.     DWORD GetModuleFileName(char *pOutName, size_t stOutSize, BOOL bFullPath = FALSE);
  71.  
  72. public:
  73.     //  Consumer implementation of DllGetClassObject per DLL
  74.     //      task instance.
  75.     virtual HRESULT GetClassObject(REFCLSID rClsid, REFIID rIid, LPVOID *ppObj) = 0;
  76.     //  Consumer implemenation of Dll[Un]RegisterServer to
  77.     //      write / delete CLSIDs for objects it implements.
  78.     //  No need to override unless you need to do more than
  79.     //      base implementation.
  80.     virtual HRESULT RegisterServer();
  81.     virtual HRESULT UnregisterServer();
  82.     //  Needed by RegisterServer and UnregisterServer.
  83.     //  Simply return an array of CLSIDs, terminated by a
  84.     //      null.
  85.     //  Must return an allocated buffer which must be freed by the
  86.     //      caller.
  87.     virtual const CLSID **GetCLSIDs() = 0;
  88.  
  89. #ifdef DLL_DEBUG
  90. public:
  91.     //  Mainly needed to distinguish trace output.
  92.     //  Set to your own string when you need to.
  93.     static const char *m_pTraceID;
  94. #endif
  95. };
  96.  
  97. #endif // __DllCommon_H