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.

91 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 1985 - 1999, Microsoft Corporation
  3. Module Name:
  4. atom.cpp
  5. Abstract:
  6. This file implements the CAtomObject class.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #include "private.h"
  12. #include "atom.h"
  13. #include "globals.h"
  14. //+---------------------------------------------------------------------------
  15. //
  16. // CAtomObject
  17. //
  18. //----------------------------------------------------------------------------
  19. HRESULT
  20. CAtomObject::_InitAtom(
  21. LPCTSTR lpString
  22. )
  23. {
  24. HRESULT hr;
  25. size_t cch;
  26. if (m_AtomName)
  27. return S_OK;
  28. hr = StringCchLength(lpString, 255, &cch);
  29. if (hr != S_OK)
  30. return hr;
  31. m_AtomName = new TCHAR[cch+1];
  32. if (m_AtomName == NULL)
  33. return E_OUTOFMEMORY;
  34. hr = StringCchCopy(m_AtomName, cch+1, lpString);
  35. return hr;
  36. }
  37. HRESULT
  38. CAtomObject::_Activate()
  39. {
  40. EnterCriticalSection(g_cs);
  41. int ref = ++m_AtomRefCount;
  42. if (ref == 1) {
  43. //
  44. // Add AIMM1.2 ATOM
  45. //
  46. m_Atom = AddAtom(m_AtomName);
  47. }
  48. LeaveCriticalSection(g_cs);
  49. return S_OK;
  50. }
  51. HRESULT
  52. CAtomObject::_Deactivate()
  53. {
  54. EnterCriticalSection(g_cs);
  55. int ref = --m_AtomRefCount;
  56. if (ref == 0) {
  57. //
  58. // Delete AIMM1.2 ATOM
  59. //
  60. DeleteAtom(m_Atom);
  61. m_Atom = 0;
  62. }
  63. LeaveCriticalSection(g_cs);
  64. return S_OK;
  65. }