1 /*############################################################################
2 # Copyright (C) Intel Corporation
4 # SPDX-License-Identifier: MIT
5 ############################################################################*/
7 #ifndef DISPATCHER_WINDOWS_MFX_WIN_REG_KEY_H_
8 #define DISPATCHER_WINDOWS_MFX_WIN_REG_KEY_H_
11 #include "vpl/mfxcommon.h"
12 #include "windows/mfx_dispatcher_log.h"
14 #if !defined(MEDIASDK_UWP_DISPATCHER)
21 enum { type = REG_DWORD };
24 struct RegKey<mfxU32> {
25 enum { type = REG_DWORD };
28 struct RegKey<mfxVersion> {
29 enum { type = REG_DWORD };
32 struct RegKey<char *> {
33 enum { type = REG_SZ };
36 struct RegKey<wchar_t *> {
37 enum { type = REG_SZ };
42 // Default constructor
47 // Open a registry key
48 bool Open(HKEY hRootKey, const wchar_t *pSubKey, REGSAM samDesired);
49 bool Open(WinRegKey &rootKey, const wchar_t *pSubKey, REGSAM samDesired);
52 bool QueryInfo(LPDWORD lpcSubkeys);
54 bool QueryValueSize(const wchar_t *pValueName, DWORD type, LPDWORD pcbData);
55 bool Query(const wchar_t *pValueName, DWORD type, LPBYTE pData, LPDWORD pcbData);
57 bool Query(const wchar_t *pValueName, wchar_t *pData, mfxU32 &nData) {
58 DWORD dw = (DWORD)nData;
59 if (!Query(pValueName, RegKey<wchar_t *>::type, (LPBYTE)pData, &dw)) {
66 // Enumerate value names
67 bool EnumValue(DWORD index, wchar_t *pValueName, LPDWORD pcchValueName, LPDWORD pType);
68 bool EnumKey(DWORD index, wchar_t *pValueName, LPDWORD pcchValueName);
74 HKEY m_hKey; // (HKEY) handle to the opened key
77 // unimplemented by intent to make this class non-copyable
78 WinRegKey(const WinRegKey &);
79 void operator=(const WinRegKey &);
83 inline bool QueryKey(WinRegKey &key, const wchar_t *pValueName, T &data) {
84 DWORD size = sizeof(data);
85 return key.Query(pValueName, RegKey<T>::type, (LPBYTE)&data, &size);
89 inline bool QueryKey<bool>(WinRegKey &key, const wchar_t *pValueName, bool &data) {
91 bool bRes = QueryKey(key, pValueName, value);
97 #endif // #if !defined(MEDIASDK_UWP_DISPATCHER)
99 #endif // DISPATCHER_WINDOWS_MFX_WIN_REG_KEY_H_