Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/shared/Registry.h

Issue 5171515343503360: Issue #41 - Bring method of determining IE version up to date (Closed)
Left Patch Set: Second version Created June 25, 2014, 6:53 p.m.
Right Patch Set: Final (?) 2 Created Jan. 5, 2015, 1:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 #ifndef REGISTRY_H
2 #define REGISTRY_H
3
4 #include <string>
5 #include <Windows.h>
6
7 namespace AdblockPlus
8 {
9 /**
10 * An open key in the system registry.
11 *
12 * This class is not completely general.
13 * In particular, it cannot encapsulate the predefined registry keys
14 * such as HKEY_CLASSES_ROOT.
15 * These classes are considered "always open",
16 * and the destructor should not close them.
17 * Rather than trying to detect these predefined keys,
18 * we simply don't allow them to be constructed.
19 * In practice, this is a limitation without much consequence.
20 * If this were a library designed for standalone use,
21 * this limitation might not be appropriate, but it's fine here.
22 */
23 class RegistryKey
24 {
25 /**
26 * Handle to registry key that is open and not predefined.
27 */
28 HKEY key;
29
30 public:
31 /**
32 * Constructor to open a key as a subkey key of an existing parent.
33 * Opens the key with read-only access.
34 *
35 * The constructor throws if 'key_name' is not found,
36 * to preserve the invariant that the registry key is open.
37 * The constructor also throws if 'key_name' is empty,
38 * to preserve the invariant the the registry key is not predefinded.
39 *
40 * \param parent
41 * An open registry key. This may be one of the predefined keys.
42 * \param key_name
43 * Name of the subkey to be opened under the parent.
44 */
45 RegistryKey(HKEY parent, const std::wstring& key_name);
46
47 /**
48 * Destructor always closes the key.
49 */
50 ~RegistryKey();
51
52 /**
53 * Retrieve a value from a name-value pair within the present key.
54 *
55 * Throws if the name is not found within the dictionary.
56 * Throws if the name is found but is not a string.
57 */
58 std::wstring value_wstring(const std::wstring& name) const;
59 };
60 }
61
62 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld