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.

96 lines
3.5 KiB

  1. //
  2. // MODULE: RegistryMonitor.h
  3. //
  4. // PURPOSE: Monitor changes to the registry.
  5. //
  6. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  7. //
  8. // AUTHOR: Joe Mabel
  9. //
  10. // ORIGINAL DATE: 9-16-98
  11. //
  12. // NOTES:
  13. //
  14. // Version Date By Comments
  15. //--------------------------------------------------------------------
  16. // V3.0 09-16-98 JM
  17. //
  18. #if !defined(AFX_REGISTRYMONITOR_H__A3CFA77B_4D78_11D2_95F7_00C04FC22ADD__INCLUDED_)
  19. #define AFX_REGISTRYMONITOR_H__A3CFA77B_4D78_11D2_95F7_00C04FC22ADD__INCLUDED_
  20. #if _MSC_VER >= 1000
  21. #pragma once
  22. #endif // _MSC_VER >= 1000
  23. #include "DirMonitor.h"
  24. #include "apgtsregconnect.h"
  25. class CThreadPool; // forward reference
  26. class CHTMLLog; // forward reference
  27. class CRegistryMonitor : public CAPGTSRegConnector
  28. {
  29. public:
  30. enum ThreadStatus{eBeforeInit, eInit, eFail, eDefaulting, eWait, eRun, eExiting};
  31. static CString ThreadStatusText(ThreadStatus ts);
  32. private:
  33. CDirectoryMonitor & m_DirectoryMonitor; // Need access to this because CRegistryMonitor
  34. // will determine what directory needs to be monitored
  35. // and what the criteria are for files "settling down"
  36. HANDLE m_hThread;
  37. HANDLE m_hevMonitorRequested; // event to wake up RegistryMonitorTask
  38. // this allows it to be wakened other than
  39. // by the registry change event. Currently used
  40. // only for shutdown.
  41. HANDLE m_hevInitialized; // event to be set when either:
  42. // (1) CRegistryMonitor values have been initialized or
  43. // from registry
  44. // (2) We can't get registry access, so CRegistryMonitor
  45. // default values will have to do
  46. bool m_bMustStartDirMonitor; // initially true, false once we've given
  47. // DirMonitor info as to what directory to
  48. // monitor
  49. bool m_bMustStartThreadPool; // initially true, false once we've set some size for the
  50. // working-thread pool
  51. HANDLE m_hevThreadIsShut; // event just to indicate exit of RegistryMonitorTask thread
  52. bool m_bShuttingDown; // lets registry monitor thread know we're shutting down
  53. DWORD m_dwErr; // status from starting the thread
  54. ThreadStatus m_ThreadStatus;
  55. time_t m_time; // time last changed ThreadStatus. Initialized
  56. // to zero ==> unknown
  57. CThreadPool * m_pThreadPool; // pointer to pool of working threads
  58. CString m_strTopicName; // This string is ignored in the Online Troubleshooter.
  59. // Done under the guise of binary compatibility.
  60. CHTMLLog *m_pLog; // pointer to the logging object so that we can
  61. // change the log file directory.
  62. public:
  63. CRegistryMonitor( CDirectoryMonitor & DirectoryMonitor, CThreadPool * pThreadPool,
  64. const CString& strTopicName,
  65. CHTMLLog *pLog ); // strTopicName is ignored in the Online Troubleshooter.
  66. // Done under the guise of binary compatibility.
  67. virtual ~CRegistryMonitor();
  68. DWORD GetStatus(ThreadStatus &ts, DWORD & seconds);
  69. // NOTE that this also provides many inherited CRegistryMonitor methods
  70. private:
  71. CRegistryMonitor(); // do not instantiate
  72. void SetThreadStatus(ThreadStatus ts);
  73. // just for use by own destructor
  74. void ShutDown();
  75. // functions for use by the DirectoryMonitorTask thread.
  76. void Monitor();
  77. void AckShutDown();
  78. void LoadChangedRegistryValues();
  79. // main function of the RegistryMonitorTask thread.
  80. static UINT WINAPI RegistryMonitorTask(LPVOID lpParams);
  81. };
  82. #endif // !defined(AFX_REGISTRYMONITOR_H__A3CFA77B_4D78_11D2_95F7_00C04FC22ADD__INCLUDED_)