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.

55 lines
1.4 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Windows NT Active Directory Property Page Sample
  4. //
  5. // The code contained in this source file is for demonstration purposes only.
  6. // No warrantee is expressed or implied and Microsoft disclaims all liability
  7. // for the consequenses of the use of this source code.
  8. //
  9. // Microsoft Windows
  10. // Copyright (C) Microsoft Corporation, 1995 - 1999
  11. //
  12. // File: dll.h
  13. //
  14. // Contents: DLL refcounting classes.
  15. //
  16. // Classes: CDll, CDllRef
  17. //
  18. // History: 6/09/1997 Eric Brown
  19. //
  20. //-----------------------------------------------------------------------------
  21. #ifndef _DLL_H_
  22. #define _DLL_H_
  23. class CDll
  24. {
  25. public:
  26. static ULONG AddRef() { return InterlockedIncrement((LONG*)&s_cObjs); }
  27. static ULONG Release() { return InterlockedDecrement((LONG*)&s_cObjs); }
  28. static void LockServer(BOOL fLock)
  29. {
  30. (fLock == TRUE) ? InterlockedIncrement((LONG*)&s_cLocks)
  31. : InterlockedDecrement((LONG*)&s_cLocks);
  32. }
  33. static HRESULT CanUnloadNow(void)
  34. {
  35. return (0L == s_cObjs && 0L == s_cLocks) ? S_OK : S_FALSE;
  36. }
  37. static ULONG s_cObjs;
  38. static ULONG s_cLocks;
  39. };
  40. class CDllRef
  41. {
  42. public:
  43. CDllRef(void) { CDll::AddRef(); }
  44. ~CDllRef(void) { CDll::Release(); }
  45. };
  46. #endif // _DLL_H_