summaryrefslogtreecommitdiffstats
path: root/chrome_frame/registry_watcher.h
blob: bb72e8278d2b73eb5759dfe0f9c8c3edf649a1ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// A utility class that makes it easy to register for registry change
// notifications.
//

#ifndef CHROME_FRAME_REGISTRY_WATCHER_H_
#define CHROME_FRAME_REGISTRY_WATCHER_H_

#include <windows.h>

class RegistryWatcher {
 public:
  typedef void (*NotifyFunc)();
  RegistryWatcher(HKEY hive, const wchar_t* path, NotifyFunc callback);
  ~RegistryWatcher();

  bool StartWatching();
  void StopWatching();

 private:
  static void CALLBACK WaitCallback(void* param, BOOLEAN wait_fired);

  HKEY registry_key_;

  HANDLE wait_event_;
  HANDLE wait_handle_;
  bool stopping_;

  NotifyFunc callback_;
};


#endif  // CHROME_FRAME_REGISTRY_WATCHER_H_