Source code of Windows XP (NT5)
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.

76 lines
2.2 KiB

  1. #ifndef _FACT_H_
  2. #define _FACT_H_
  3. #include <objbase.h>
  4. #include "factdata.h"
  5. class CCOMBase;
  6. class CCOMBaseFactory;
  7. class CCOMBaseFactory : public IClassFactory
  8. {
  9. ///////////////////////////////////////////////////////////////////////////////
  10. // COM Interfaces
  11. public:
  12. // IUnknown
  13. virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
  14. virtual STDMETHODIMP_(ULONG) AddRef();
  15. virtual STDMETHODIMP_(ULONG) Release();
  16. // IClassFactory
  17. virtual STDMETHODIMP CreateInstance(IUnknown* pUnknownOuter, REFIID riid,
  18. void** ppv);
  19. virtual STDMETHODIMP LockServer(BOOL fLock);
  20. ///////////////////////////////////////////////////////////////////////////////
  21. //
  22. public:
  23. CCOMBaseFactory(const CFactoryData* pFactoryData);
  24. ~CCOMBaseFactory() {}
  25. public: // only for use in dll.cpp, or internally
  26. static HRESULT _RegisterAll();
  27. static HRESULT _UnregisterAll();
  28. static HRESULT _CanUnloadNow();
  29. static HRESULT _CheckForUnload();
  30. ///////////////////////////////////////////////////////////////////////////////
  31. // Helpers
  32. private:
  33. static BOOL _IsLocked();
  34. static HRESULT _LockServer(BOOL fLock);
  35. static void _COMFactoryCB(BOOL fIncrement);
  36. public: // only for use in dll.cpp
  37. static HRESULT _GetClassObject(REFCLSID rclsid, REFIID riid, void** ppv);
  38. static BOOL _fCritSectInit;
  39. public: // only for use in COM exe server
  40. static BOOL _ProcessConsoleCmdLineParams(int argc, wchar_t* argv[],
  41. BOOL* pfRun, BOOL* pfEmbedded);
  42. // static BOOL _ProcessWindowsCmdLineParams(LPWSTR pszCmdLine);
  43. static void _WaitForAllClientsToGo();
  44. static BOOL _RegisterFactories(BOOL fEmbedded);
  45. static BOOL _UnregisterFactories(BOOL fEmbedded);
  46. static BOOL _SuspendFactories();
  47. static BOOL _ResumeFactories();
  48. public:
  49. const CFactoryData* _pFactoryData;
  50. static const CFactoryData* _pDLLFactoryData;
  51. static const DWORD _cDLLFactoryData;
  52. static struct OUTPROCINFO* _popinfo;
  53. static HMODULE _hModule;
  54. static CRITICAL_SECTION _cs;
  55. private:
  56. ULONG _cRef;
  57. static LONG _cComponents;
  58. static LONG _cServerLocks;
  59. static DWORD _dwThreadID;
  60. };
  61. #endif