1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 // 5 // A utility class that makes it easy to register for registry change 6 // notifications. 7 // 8 9 #ifndef CHROME_FRAME_REGISTRY_WATCHER_H_ 10 #define CHROME_FRAME_REGISTRY_WATCHER_H_ 11 12 #include <windows.h> 13 14 class RegistryWatcher { 15 public: 16 typedef void (*NotifyFunc)(); 17 RegistryWatcher(HKEY hive, const wchar_t* path, NotifyFunc callback); 18 ~RegistryWatcher(); 19 20 bool StartWatching(); 21 void StopWatching(); 22 23 private: 24 static void CALLBACK WaitCallback(void* param, BOOLEAN wait_fired); 25 26 HKEY registry_key_; 27 28 HANDLE wait_event_; 29 HANDLE wait_handle_; 30 bool stopping_; 31 32 NotifyFunc callback_; 33 }; 34 35 36 #endif // CHROME_FRAME_REGISTRY_WATCHER_H_ 37