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.

26 lines
552 B

  1. #pragma once
  2. #ifdef __ATLCOM_H__ //--- Only enable these if ATL is being used
  3. class CSPAutoObjectLock
  4. {
  5. protected:
  6. CComObjectRootEx<CComMultiThreadModel>* m_pObject;
  7. public:
  8. CSPAutoObjectLock(CComObjectRootEx<CComMultiThreadModel> * const pobject)
  9. {
  10. m_pObject = pobject;
  11. m_pObject->Lock();
  12. };
  13. ~CSPAutoObjectLock() {
  14. m_pObject->Unlock();
  15. };
  16. };
  17. #define SPAUTO_OBJ_LOCK CSPAutoObjectLock lck(this)
  18. #define SPAUTO_OBJ_LOCK_OBJECT( t ) CSPAutoObjectLock lck##__LINE__(t)
  19. #endif // __ATLCOM_H__