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.

65 lines
1.2 KiB

  1. #ifndef __MS_UTIL_H__
  2. #define __MS_UTIL_H__
  3. //
  4. // GUI message boxes kill us when we hit an assert or error, because they
  5. // have a message pump that causes messages to get dispatched, making it
  6. // very difficult for us to debug problems when they occur. Therefore
  7. // we redefine ERROR_OUT and ASSERT
  8. //
  9. #ifdef _DEBUG
  10. __inline void MyDebugBreak(void) { DebugBreak(); }
  11. #endif // _DEBUG
  12. // the following create a dword that will look like "abcd" in debugger
  13. #ifdef SHIP_BUILD
  14. #define MAKE_STAMP_ID(a,b,c,d)
  15. #else
  16. #define MAKE_STAMP_ID(a,b,c,d) MAKELONG(MAKEWORD(a,b),MAKEWORD(c,d))
  17. #endif // SHIP_BUILD
  18. class CRefCount
  19. {
  20. public:
  21. #ifdef SHIP_BUILD
  22. CRefCount(void);
  23. #else
  24. CRefCount(DWORD dwStampID);
  25. #endif
  26. virtual ~CRefCount(void) = 0;
  27. LONG AddRef(void);
  28. LONG Release(void);
  29. void ReleaseNow(void);
  30. protected:
  31. LONG GetRefCount(void) { return m_cRefs; }
  32. BOOL IsRefCountZero(void) { return (0 == m_cRefs); }
  33. private:
  34. #ifndef SHIP_BUILD
  35. DWORD m_dwStampID;// to remove before we ship it
  36. #endif
  37. LONG m_cRefs; // reference count
  38. };
  39. __inline void My_CloseHandle(HANDLE hdl)
  40. {
  41. if (NULL != hdl)
  42. {
  43. CloseHandle(hdl);
  44. }
  45. }
  46. #endif // __MS_UTIL_H__