home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples1.exe / Profiler / classfactory.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  3.6 KB  |  131 lines

  1. /****************************************************************************************
  2.  * Copyright (c) 1999 Microsoft Corporation.  All Rights Reserved.
  3.  *
  4.  * File:
  5.  *  classfactory.h
  6.  *
  7.  * Description:
  8.  *    
  9.  *
  10.  *
  11.  ***************************************************************************************/
  12. #ifndef __CLASSFACTORY_H__
  13. #define __CLASSFACTORY_H__
  14.  
  15.  
  16. #include "RegUtil.h"
  17. #include "ProfilerCallback.h"
  18.  
  19.  
  20. //
  21. // profiler GUID definition
  22. //
  23. #define PROFILER_GUID "{01568439-E2BA-4434-8ACC-816239E8B8B5}"
  24. extern const GUID __declspec( selectany ) CLSID_PROFILER = 
  25. { 0x1568439, 0xe2ba, 0x4434, { 0x8a, 0xcc, 0x81, 0x62, 0x39, 0xe8, 0xb8, 0xb5 } };
  26.  
  27.  
  28. //
  29. // Helpers/Registration
  30. //
  31. HINSTANCE g_hInst;          // instance handle to this piece of code
  32. const int g_iVersion = 1; // version of coclasses.
  33.  
  34. static const LPCSTR g_szCoclassDesc    = "Microsoft NGWS Profiler";
  35. static const LPCSTR g_szProgIDPrefix   = "Profiler Monitoring Tool";
  36. static const LPCSTR g_szThreadingModel = "Both";
  37.  
  38.  
  39. // create a new instance of an object.
  40. typedef HRESULT (* PFN_CREATE_OBJ)( REFIID riid, void **ppInterface );
  41.  
  42.  
  43. /***************************************************************************************
  44.  ********************                                               ********************
  45.  ********************         COCLASS_REGISTER Declaration          ********************
  46.  ********************                                               ********************
  47.  ***************************************************************************************/
  48. struct COCLASS_REGISTER
  49. {    
  50.     const GUID *pClsid;                // Class ID of the coclass
  51.     const char *szProgID;            // Prog ID of the class
  52.        PFN_CREATE_OBJ pfnCreateObject;    // function to create instance
  53.     
  54. }; // COCLASS_REGISTER
  55.  
  56.  
  57. // this map contains the list of coclasses which are exported from this module
  58. const COCLASS_REGISTER g_CoClasses[] =
  59. {    
  60.     &CLSID_PROFILER,
  61.     PROFILER_GUID,             
  62.     ProfilerCallback::CreateObject,
  63.     NULL,                
  64.     NULL,                
  65.     NULL
  66. };
  67.  
  68.  
  69. /***************************************************************************************
  70.  ********************                                               ********************
  71.  ********************          CClassFactory Declaration            ********************
  72.  ********************                                               ********************
  73.  ***************************************************************************************/
  74. class CClassFactory :
  75.     public IClassFactory
  76. {
  77.     private:
  78.     
  79.         CClassFactory();                        
  80.         
  81.     
  82.     public:
  83.     
  84.         CClassFactory( const COCLASS_REGISTER *pCoClass );
  85.         ~CClassFactory();
  86.         
  87.  
  88.     public:
  89.     
  90.         //
  91.         // IUnknown 
  92.         //
  93.           COM_METHOD( ULONG ) AddRef();        
  94.         COM_METHOD( ULONG ) Release();
  95.         COM_METHOD( HRESULT ) QueryInterface( REFIID riid, void    **ppInterface );               
  96.         
  97.         //
  98.         // IClassFactory 
  99.         //
  100.         COM_METHOD( HRESULT ) LockServer( BOOL fLock );
  101.         COM_METHOD( HRESULT ) CreateInstance( IUnknown *pUnkOuter,
  102.                                               REFIID riid,
  103.                                               void **ppInterface );
  104.     
  105.     
  106.     private:
  107.     
  108.         long m_refCount;                        
  109.         const COCLASS_REGISTER *m_pCoClass;        
  110.         
  111. }; // CClassFactory
  112.  
  113.  
  114. //
  115. // function prototypes
  116. //
  117. HINSTANCE GetModuleInst();
  118. STDAPI DllRegisterServer();
  119. STDAPI DllUnregisterServer();
  120. STDAPI DllGetClassObject( REFCLSID rclsid, /* class desired */
  121.                           REFIID riid,       /* interface desired    */
  122.                           LPVOID FAR *ppv  /* return interface pointer */ );
  123.  
  124.  
  125. #endif // __CLASSFACTORY_H__
  126.  
  127. // End of File
  128.  
  129.  
  130.  
  131.