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.

102 lines
2.4 KiB

  1. #ifndef _PSSCLASS_HXX_
  2. #define _PSSCLASS_HXX_
  3. #include <propstm.hxx>
  4. #include <pstgserv.h> // IDL headers
  5. #include <instant.hxx> // Instantiation of function pointers.
  6. class CPropertyStorageServer : public IPropertyStorageServer
  7. {
  8. public:
  9. CPropertyStorageServer( IClassFactory *pcf)
  10. {
  11. m_cRefs = 0;
  12. m_pcf = pcf;
  13. m_pcf->LockServer( TRUE );
  14. m_pstg = NULL;
  15. }
  16. ~CPropertyStorageServer()
  17. {
  18. if( m_cRefs > 0 )
  19. {
  20. CoDisconnectObject( this, 0L );
  21. }
  22. if( m_pstg != NULL )
  23. m_pstg->Release();
  24. m_pcf->LockServer( FALSE );
  25. if( NULL != g_hinstDLL )
  26. {
  27. FreeLibrary( g_hinstDLL );
  28. g_hinstDLL = NULL;
  29. }
  30. }
  31. STDMETHODIMP QueryInterface( REFIID riid, void **ppvObj );
  32. STDMETHODIMP_(ULONG) AddRef(void);
  33. STDMETHODIMP_(ULONG) Release(void);
  34. STDMETHODIMP StgOpenPropStg( const OLECHAR *pwcsName,
  35. REFFMTID fmtid,
  36. DWORD grfMode,
  37. IPropertyStorage **pppstg );
  38. STDMETHODIMP StgOpenPropSetStg( const OLECHAR *pwcsName,
  39. DWORD grfMode,
  40. IPropertySetStorage **pppsstg );
  41. STDMETHODIMP MarshalUnknown( IUnknown *punk );
  42. STDMETHODIMP Initialize( EnumImplementation enumImplementation,
  43. ULONG Restrictions );
  44. private:
  45. IStorage * m_pstg;
  46. ULONG m_cRefs;
  47. IClassFactory *m_pcf;
  48. };
  49. class CClassFactory: public IClassFactory
  50. {
  51. public:
  52. CClassFactory( HWND hWnd )
  53. {
  54. m_cRefs = 0;
  55. m_cLocks = 0;
  56. m_hWnd = hWnd;
  57. }
  58. ~CClassFactory()
  59. {
  60. if( m_cRefs > 0 )
  61. {
  62. CoDisconnectObject( this, 0L );
  63. }
  64. SendMessage( m_hWnd, WM_QUIT, 0, 0 );
  65. }
  66. public:
  67. STDMETHODIMP QueryInterface( REFIID riid, void **ppvObj );
  68. STDMETHODIMP_(ULONG) AddRef(void);
  69. STDMETHODIMP_(ULONG) Release(void);
  70. STDMETHODIMP CreateInstance( IUnknown *pUnkOuter,
  71. REFIID riid,
  72. void **ppvObject );
  73. STDMETHODIMP LockServer( BOOL fLock );
  74. private:
  75. ULONG m_cLocks;
  76. HWND m_hWnd;
  77. ULONG m_cRefs;
  78. };
  79. #endif // _PSSCLASS_HXX_