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.

78 lines
1.8 KiB

  1. //____________________________________________________________________________
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995 - 1999
  5. //
  6. // File: dll.h
  7. //
  8. // Contents: DLL refcounting classes, wait cursor class, and error reporting
  9. // functions.
  10. //
  11. // Classes: CDll, CDllRef
  12. //
  13. // History: 1/24/1996 RaviR Created
  14. // 6/09/1997 EricB Error Reporting.
  15. //
  16. //____________________________________________________________________________
  17. #ifndef _DLL_H_
  18. #define _DLL_H_
  19. #define MAX_TITLE 80
  20. #define MAX_MSG_LEN 512
  21. #define MAX_ERRORMSG MAX_MSG_LEN
  22. void LoadErrorMessage(HRESULT hr, int nStr, PTSTR* pptsz);
  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. (fLock == TRUE) ? InterlockedIncrement((LONG*)&s_cLocks)
  30. : InterlockedDecrement((LONG*)&s_cLocks);
  31. }
  32. static HRESULT CanUnloadNow(void) {
  33. return (0L == s_cObjs && 0L == s_cLocks) ? S_OK : S_FALSE;
  34. }
  35. static ULONG s_cObjs;
  36. static ULONG s_cLocks;
  37. }; // class CDll
  38. class CDllRef
  39. {
  40. public:
  41. CDllRef(void) { CDll::AddRef(); }
  42. ~CDllRef(void) { CDll::Release(); }
  43. }; // class CDllRef
  44. class CWaitCursor
  45. {
  46. public:
  47. CWaitCursor() {m_cOld=SetCursor(m_cWait=LoadCursor(NULL, IDC_WAIT));}
  48. ~CWaitCursor() {SetCursor(m_cOld);}
  49. void SetWait() {SetCursor(m_cWait);}
  50. void SetOld() {SetCursor(m_cOld);}
  51. private:
  52. HCURSOR m_cWait;
  53. HCURSOR m_cOld;
  54. } ;
  55. // This wrapper function required to make prefast shut up when we are
  56. // initializing a critical section in a constructor.
  57. void ExceptionPropagatingInitializeCriticalSection(LPCRITICAL_SECTION critsec);
  58. #endif // _DLL_H_