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 / chap09 / linksrc / linksrc.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  2KB  |  95 lines

  1. /*
  2.  * LINKSRC.H
  3.  * Link Source Server Chapter 9
  4.  *
  5.  * Definitions, classes, and prototypes for an application that
  6.  * serves file objects and support moniker binding.
  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 _LINKSRC_H_
  17. #define _LINKSRC_H_
  18.  
  19. #include "objects.h"
  20.  
  21. #define IDR_MENU            1
  22.  
  23. #define IDM_FILECREATEGOOP  100
  24. #define IDM_FILEEXIT        101
  25.  
  26.  
  27. //Name of streams in the source file that holds description text.
  28. #define SZDESCRIPTION       OLETEXT("Description")
  29.  
  30.  
  31.  
  32. //LINKSRC.CPP
  33. LRESULT APIENTRY LinkSrcWndProc(HWND, UINT, WPARAM, LPARAM);
  34.  
  35. class CApp
  36.     {
  37.     friend LRESULT APIENTRY LinkSrcWndProc(HWND, UINT, WPARAM, LPARAM);
  38.  
  39.     protected:
  40.         HINSTANCE       m_hInst;            //WinMain parameters
  41.         HINSTANCE       m_hInstPrev;
  42.         LPSTR           m_pszCmdLine;
  43.         UINT            m_nCmdShow;
  44.  
  45.         HWND            m_hWnd;             //Main window handle
  46.  
  47.         BOOL            m_fEmbedding;       //-Embedding found?
  48.         BOOL            m_fInitialized;     //Did CoInitialize work?
  49.         LPCLASSFACTORY  m_pIClassFactory;   //Our class factory
  50.         DWORD           m_dwRegCO;          //Registration key
  51.  
  52.     public:
  53.         CApp(HINSTANCE, HINSTANCE, LPSTR, UINT);
  54.         ~CApp(void);
  55.         BOOL Init(void);
  56.  
  57.         void     CreateSampleFile(LPTSTR);
  58.         HRESULT  CreateStore(IStorage *, LPTSTR, LPTSTR, UINT);
  59.         HRESULT  WriteDescription(IStorage *, LPTSTR);
  60.     };
  61.  
  62. typedef CApp *PAPP;
  63.  
  64. #define CBWNDEXTRA              sizeof(PAPP)
  65. #define LINKSRCWL_STRUCTURE     0
  66.  
  67.  
  68. void ObjectDestroyed(void);
  69.  
  70.  
  71. //LINKSRC.CPP
  72.  
  73. class CFileObjectFactory : public IClassFactory
  74.     {
  75.     protected:
  76.         ULONG                       m_cRef;
  77.  
  78.     public:
  79.         CFileObjectFactory(void);
  80.         ~CFileObjectFactory(void);
  81.  
  82.         //IUnknown members
  83.         STDMETHODIMP QueryInterface(REFIID, PPVOID);
  84.         STDMETHODIMP_(ULONG) AddRef(void);
  85.         STDMETHODIMP_(ULONG) Release(void);
  86.  
  87.         //IClassFactory members
  88.         STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, PPVOID);
  89.         STDMETHODIMP LockServer(BOOL);
  90.     };
  91.  
  92. typedef CFileObjectFactory *PCFileObjectFactory;
  93.  
  94. #endif //_LINKSRC_H_
  95.