1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2  * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_TestShellEx_RegUtils_h
8 #define mozilla_TestShellEx_RegUtils_h
9 
10 #include <string>
11 
12 class RegKey final {
13   HKEY mKey;
14 
15   bool SetStringInternal(const wchar_t* aValueName, const wchar_t* aValueData,
16                          DWORD aValueDataLength);
17 
18  public:
RegKey()19   RegKey() : mKey(nullptr) {}
20   RegKey(HKEY root, const wchar_t* aSubkey);
21   ~RegKey();
22 
23   RegKey(RegKey&& aOther) = delete;
24   RegKey& operator=(RegKey&& aOther) = delete;
25   RegKey(const RegKey&) = delete;
26   RegKey& operator=(const RegKey&) = delete;
27 
28   explicit operator bool() const { return !!mKey; }
HKEY()29   operator HKEY() const { return mKey; }
30 
31   bool SetString(const wchar_t* aValueName,
32                  const wchar_t* aValueData = nullptr);
33   bool SetString(const wchar_t* aValueName, const std::wstring& aValueData);
34   std::wstring GetString(const wchar_t* aValueName);
35 };
36 
37 class ComRegisterer final {
38   RegKey mClassRoot;
39   std::wstring mClsId;
40   std::wstring mFriendlyName;
41 
42  public:
43   ComRegisterer(const GUID& aClsId, const wchar_t* aFriendlyName);
44   ~ComRegisterer() = default;
45 
46   bool UnregisterAll();
47   bool RegisterObject(const wchar_t* aThreadModel);
48   bool RegisterExtensions();
49 };
50 
51 #endif  // mozilla_TestShellEx_RegUtils_h
52