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.

79 lines
2.4 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 DllAttach(HINSTANCE hinst);
  27. static HRESULT DllDetach();
  28. static HRESULT _RegisterAll();
  29. static HRESULT _UnregisterAll();
  30. static HRESULT _CanUnloadNow();
  31. static HRESULT _CheckForUnload();
  32. ///////////////////////////////////////////////////////////////////////////////
  33. // Helpers
  34. private:
  35. static BOOL _IsLocked();
  36. static HRESULT _LockServer(BOOL fLock);
  37. static void _COMFactoryCB(BOOL fIncrement);
  38. public: // only for use in dll.cpp
  39. static HRESULT _GetClassObject(REFCLSID rclsid, REFIID riid, void** ppv);
  40. public: // only for use in COM exe server
  41. static BOOL _ProcessConsoleCmdLineParams(int argc, wchar_t* argv[],
  42. BOOL* pfRun, BOOL* pfEmbedded);
  43. // static BOOL _ProcessWindowsCmdLineParams(LPWSTR pszCmdLine);
  44. static void _WaitForAllClientsToGo();
  45. static BOOL _RegisterFactories(BOOL fEmbedded);
  46. static BOOL _UnregisterFactories(BOOL fEmbedded);
  47. static BOOL _SuspendFactories();
  48. static BOOL _ResumeFactories();
  49. public:
  50. const CFactoryData* _pFactoryData;
  51. static const CFactoryData* _pDLLFactoryData;
  52. static const DWORD _cDLLFactoryData;
  53. static struct OUTPROCINFO* _popinfo;
  54. static HMODULE _hModule;
  55. static CRITICAL_SECTION _cs;
  56. private:
  57. LONG _cRef;
  58. static LONG _cComponents;
  59. static LONG _cServerLocks;
  60. static DWORD _dwThreadID;
  61. static BOOL _fCritSectInit;
  62. };
  63. #endif