home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / chap05 / ekoala2 / ekoala2.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  2KB  |  87 lines

  1. /*
  2.  * EKOALA2.H
  3.  * Koala Object EXE Self-Registering Server Chapter 5
  4.  *
  5.  * Definitions, classes, and prototypes for an application that
  6.  * provides Koala objects to any other object user.
  7.  *
  8.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Microsoft
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #ifndef _EKOALA2_H_
  17. #define _EKOALA2_H_
  18.  
  19.  
  20. //Get the object definitions
  21. #include "koala.h"
  22.  
  23.  
  24. //EKOALA2.CPP
  25. LRESULT APIENTRY KoalaWndProc(HWND, UINT, WPARAM, LPARAM);
  26.  
  27. class CApp
  28.     {
  29.     friend LRESULT APIENTRY KoalaWndProc(HWND, UINT, WPARAM, LPARAM);
  30.  
  31.     protected:
  32.         HINSTANCE       m_hInst;            //WinMain parameters
  33.         HINSTANCE       m_hInstPrev;
  34.         LPSTR           m_pszCmdLine;
  35.         UINT            m_nCmdShow;
  36.  
  37.         HWND            m_hWnd;             //Main window handle
  38.  
  39.         BOOL            m_fInitialized;     //Did CoInitialize work?
  40.         LPCLASSFACTORY  m_pIClassFactory;   //Our class factory
  41.         DWORD           m_dwRegCO;          //Registration key
  42.  
  43.     private:
  44.         BOOL SetKeyAndValue(LPTSTR, LPTSTR, LPTSTR);
  45.  
  46.     public:
  47.         CApp(HINSTANCE, HINSTANCE, LPSTR, UINT);
  48.         ~CApp(void);
  49.         BOOL Init(void);
  50.         void RegisterServer(void);
  51.         void UnregisterServer(void);
  52.     };
  53.  
  54. typedef CApp *PAPP;
  55.  
  56. #define CBWNDEXTRA              sizeof(PAPP)
  57. #define KOALAWL_STRUCTURE       0
  58.  
  59.  
  60. void ObjectDestroyed(void);
  61.  
  62.  
  63. //This class factory object creates Koala objects.
  64.  
  65. class CKoalaClassFactory : public IClassFactory
  66.     {
  67.     protected:
  68.         ULONG           m_cRef;
  69.  
  70.     public:
  71.         CKoalaClassFactory(void);
  72.         ~CKoalaClassFactory(void);
  73.  
  74.         //IUnknown members
  75.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  76.         STDMETHODIMP_(ULONG) AddRef(void);
  77.         STDMETHODIMP_(ULONG) Release(void);
  78.  
  79.         //IClassFactory members
  80.         STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, PPVOID);
  81.         STDMETHODIMP LockServer(BOOL);
  82.     };
  83.  
  84. typedef CKoalaClassFactory *PCKoalaClassFactory;
  85.  
  86. #endif //_EKOALA2_H_
  87.