Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.1 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1997
  4. *
  5. * TITLE: WiaCFact.h
  6. *
  7. * VERSION: 2.0
  8. *
  9. * AUTHOR: ReedB
  10. *
  11. * DATE: 26 Dec, 1997
  12. *
  13. * DESCRIPTION:
  14. * Declarations and definitions for Class factory.
  15. *
  16. *******************************************************************************/
  17. typedef HRESULT (*FPCREATEINSTANCE)(const IID& iid, void** ppv);
  18. // FACTORY_DATA - Information CFactory needs to create a component
  19. typedef struct _FACTORY_DATA
  20. {
  21. FPCREATEINSTANCE CreateInstance; // Pointer to creating function.
  22. IClassFactory* pIClassFactory; // Pointer to running class factory.
  23. DWORD dwRegister; // ID for running object.
  24. const CLSID* pclsid; // The class ID for the component.
  25. const GUID* plibid; // Type library ID.
  26. // Registry strings:
  27. LPCTSTR szRegName; // Name of the component.
  28. LPCTSTR szProgID; // Program ID.
  29. LPCTSTR szVerIndProgID; // Version-independent program ID.
  30. LPCTSTR szService; // Name of service.
  31. LPCTSTR szModuleFileName; // Filename of module.
  32. } FACTORY_DATA, *PFACTORY_DATA;
  33. // Class Factory
  34. class CFactory : public IClassFactory
  35. {
  36. public:
  37. // IUnknown
  38. virtual HRESULT __stdcall QueryInterface(const IID& iid, void** ppv) ;
  39. virtual ULONG __stdcall AddRef() ;
  40. virtual ULONG __stdcall Release() ;
  41. // IClassFactory
  42. virtual HRESULT __stdcall CreateInstance(IUnknown* pUnknownOuter,
  43. const IID& iid,
  44. void** ppv) ;
  45. virtual HRESULT __stdcall LockServer(BOOL bLock) ;
  46. // Constructor - Pass pointer to data of component to create.
  47. CFactory(const PFACTORY_DATA pFactoryData);
  48. // Destructor
  49. ~CFactory() { }
  50. // Static FactoryData support functions
  51. // Helper function for CanUnloadNow
  52. static BOOL IsLocked()
  53. { return (s_cServerLocks > 0) ;}
  54. // Functions to [un]register all components
  55. static HRESULT RegisterUnregisterAll(
  56. PFACTORY_DATA pFactoryData,
  57. UINT uiFactoryDataCount,
  58. BOOLEAN bRegister,
  59. BOOLEAN bOutProc);
  60. // Function to determine if component can be unloaded
  61. static HRESULT CanUnloadNow() ;
  62. // Out-of-process server support
  63. static BOOL StartFactories(
  64. PFACTORY_DATA pFactoryData,
  65. UINT uiFactoryDataCount);
  66. static void StopFactories(
  67. PFACTORY_DATA pFactoryData,
  68. UINT uiFactoryDataCount);
  69. static DWORD s_dwThreadID ;
  70. // Shut down the application.
  71. static void CloseExe()
  72. {
  73. if (CanUnloadNow() == S_OK)
  74. {
  75. ::PostThreadMessage(s_dwThreadID, WM_QUIT, 0, 0) ;
  76. }
  77. }
  78. public:
  79. // Reference Count
  80. LONG m_cRef ;
  81. // Pointer to information about class this factory creates
  82. PFACTORY_DATA m_pFactoryData;
  83. // Count of locks
  84. static LONG s_cServerLocks;
  85. // Module handle
  86. static HMODULE s_hModule;
  87. } ;