diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/registry.cc | 9 | ||||
-rw-r--r-- | base/registry.h | 1 |
2 files changed, 4 insertions, 6 deletions
diff --git a/base/registry.cc b/base/registry.cc index b5e5b32..e5709f2 100644 --- a/base/registry.cc +++ b/base/registry.cc @@ -351,8 +351,9 @@ bool RegKey::DeleteValue(const tchar * value_name) { } bool RegKey::StartWatching() { - assert(watch_event_ == 0); - watch_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); + if (!watch_event_) + watch_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); + DWORD filter = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET | @@ -382,10 +383,6 @@ bool RegKey::StopWatching() { bool RegKey::HasChanged() { if (watch_event_) { if (WaitForSingleObject(watch_event_, 0) == WAIT_OBJECT_0) { - // An event only gets signaled once, then it's done, so we have - // to set up another event to watch. - CloseHandle(watch_event_); - watch_event_ = 0; StartWatching(); return true; } diff --git a/base/registry.h b/base/registry.h index a2f6fd8..757e409 100644 --- a/base/registry.h +++ b/base/registry.h @@ -88,6 +88,7 @@ class RegKey { bool StopWatching(); inline bool IsWatching() const { return watch_event_ != 0; } + HANDLE watch_event() const { return watch_event_; } HKEY Handle() const { return key_; } private: |