ReactOS 0.4.17-dev-243-g1369312
CRegistrySource Class Reference
Inheritance diagram for CRegistrySource:
Collaboration diagram for CRegistrySource:

Public Member Functions

virtual ~CRegistrySource ()
 
HRESULT Init (HKEY hKey, PCWSTR pszSubKey, BOOL bCreate)
 
STDMETHODIMP QueryInterface (REFIID riid, void **ppvObject) override
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
STDMETHODIMP EnumValues (IEnumString **ppEnum) override
 
STDMETHODIMP EnumSources (IEnumString **ppEnum) override
 
STDMETHODIMP QueryValueString (PCWSTR keyName, PCWSTR valueName, PWSTR *ppszValue) override
 
STDMETHODIMP QueryValueDword (PCWSTR keyName, PCWSTR valueName, DWORD *pdwValue) override
 
STDMETHODIMP QueryValueExists (PCWSTR keyName, PCWSTR valueName) override
 
STDMETHODIMP QueryValueDirect (PCWSTR keyName, PCWSTR valueName, FLAGGED_BYTE_BLOB **ppBlob) override
 
STDMETHODIMP OpenSource (PCWSTR keyName, BOOL bCreate, IQuerySourceOld **ppSource) override
 
STDMETHODIMP SetValueDirect (PCWSTR keyName, PCWSTR valueName, DWORD dwType, DWORD cbData, LPCVOID pvData) override
 
STDMETHODIMP SetKey (HKEY hKey) override
 
STDMETHODIMP GetKey (HKEY *phKey) override
 

Private Attributes

LONG m_cRefs = 1
 
HKEY m_hKey = NULL
 

Detailed Description

Definition at line 90 of file querysrc.cpp.

Constructor & Destructor Documentation

◆ ~CRegistrySource()

CRegistrySource::~CRegistrySource ( )
virtual

Definition at line 253 of file querysrc.cpp.

254{
255 if (m_hKey)
257}
#define RegCloseKey(hKey)
Definition: registry.h:49

Member Function Documentation

◆ EnumSources()

STDMETHODIMP CRegistrySource::EnumSources ( IEnumString **  ppEnum)
override

Definition at line 319 of file querysrc.cpp.

320{
322 HRESULT hr = pEnum->Init(m_hKey, this);
323 if (FAILED(hr))
324 {
325 pEnum->Release();
326 pEnum = NULL;
327 }
328 *ppEnum = pEnum;
329 return pEnum ? S_OK : E_OUTOFMEMORY;
330}
HRESULT Init(HKEY hKey, CRegistrySource *pSource)
Definition: querysrc.cpp:132
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51

◆ EnumValues()

STDMETHODIMP CRegistrySource::EnumValues ( IEnumString **  ppEnum)
override

Definition at line 306 of file querysrc.cpp.

307{
309 HRESULT hr = pEnum->Init(m_hKey, this);
310 if (FAILED(hr))
311 {
312 pEnum->Release();
313 pEnum = NULL;
314 }
315 *ppEnum = pEnum;
316 return pEnum ? S_OK : E_OUTOFMEMORY;
317}

◆ GetKey()

STDMETHODIMP CRegistrySource::GetKey ( HKEY phKey)
override

Definition at line 475 of file querysrc.cpp.

476{
477 if (!m_hKey)
478 return E_UNEXPECTED;
479
480 *phKey = SHRegDuplicateHKey(m_hKey);
481 if (!*phKey)
482 return E_UNEXPECTED;
483
484 return S_OK;
485}
HKEY WINAPI SHRegDuplicateHKey(HKEY hKey)
Definition: reg.c:2256
#define E_UNEXPECTED
Definition: winerror.h:3528

◆ Init()

HRESULT CRegistrySource::Init ( HKEY  hKey,
PCWSTR  pszSubKey,
BOOL  bCreate 
)

Definition at line 259 of file querysrc.cpp.

260{
262 if (bCreate)
264 else
266
268}
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
FxAutoRegKey hKey
#define error(str)
Definition: mkdosfs.c:1605
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
_In_opt_ LPCSTR pszSubKey
Definition: shlwapi.h:783
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1527
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

Referenced by QuerySourceCreateFromKey().

◆ OpenSource()

STDMETHODIMP CRegistrySource::OpenSource ( PCWSTR  keyName,
BOOL  bCreate,
IQuerySourceOld **  ppSource 
)
override

Definition at line 448 of file querysrc.cpp.

449{
450 return QuerySourceCreateFromKey(m_hKey, keyName, bCreate, IID_IQuerySourceOld, (PVOID*)ppSource);
451}
EXTERN_C HRESULT WINAPI QuerySourceCreateFromKey(_In_ HKEY hKey, _In_opt_ PCWSTR lpSubKey, _In_ BOOL bCreate, _In_ REFIID riid, _Outptr_ PVOID *ppv)
Definition: querysrc.cpp:494

◆ QueryInterface()

STDMETHODIMP CRegistrySource::QueryInterface ( REFIID  riid,
void **  ppvObject 
)
override

Definition at line 270 of file querysrc.cpp.

271{
272 if (!ppvObject)
273 return E_POINTER;
274
275 if (riid == IID_IQuerySourceOld)
276 {
277 *ppvObject = static_cast<IQuerySourceOld*>(this);
278 AddRef();
279 return S_OK;
280 }
281
282 if (riid == IID_IObjectWithRegistryKeyOld)
283 {
284 *ppvObject = static_cast<IObjectWithRegistryKeyOld*>(this);
285 AddRef();
286 return S_OK;
287 }
288
289 *ppvObject = NULL;
290 return E_NOINTERFACE;
291}
REFIID riid
Definition: atlbase.h:39
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:83
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_POINTER
Definition: winerror.h:3480

Referenced by QuerySourceCreateFromKey().

◆ QueryValueDirect()

STDMETHODIMP CRegistrySource::QueryValueDirect ( PCWSTR  keyName,
PCWSTR  valueName,
FLAGGED_BYTE_BLOB **  ppBlob 
)
override

Definition at line 396 of file querysrc.cpp.

400{
401 HRESULT hr = E_FAIL;
402 HKEY hKey = m_hKey;
403 DWORD dwType = REG_NONE;
404 DWORD cbData = 256;
405 BYTE abData[256];
406
407 *ppBlob = NULL;
408
409 if (keyName && *keyName &&
411 {
412 return E_FAIL;
413 }
414
415 LSTATUS error = RegQueryValueExW(hKey, valueName, NULL, &dwType, abData, &cbData);
416 if (error == ERROR_SUCCESS)
417 {
418 hr = SHAllocBlob(cbData, abData, ppBlob);
419 }
420 else if (error == ERROR_MORE_DATA)
421 {
422 hr = SHAllocBlob(cbData, NULL, ppBlob);
423 if (SUCCEEDED(hr))
424 {
425 error = RegQueryValueExW(hKey, valueName, NULL, &dwType, (*ppBlob)->abData, &cbData);
426 if (error != ERROR_SUCCESS)
427 {
428 CoTaskMemFree(*ppBlob);
429 *ppBlob = NULL;
431 }
432 }
433 }
434 else
435 {
437 }
438
439 if (hKey != m_hKey)
441
442 if (SUCCEEDED(hr))
443 (*ppBlob)->fFlags = dwType;
444
445 return hr;
446}
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SUCCEEDED(hr)
Definition: intsafe.h:50
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define KEY_READ
Definition: nt_native.h:1026
#define REG_NONE
Definition: nt_native.h:1495
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761
static HRESULT SHAllocBlob(ULONG cbData, const BYTE *pbData, FLAGGED_BYTE_BLOB **ppBlob)
Definition: querysrc.cpp:16
unsigned char BYTE
Definition: xxhash.c:193

◆ QueryValueDword()

STDMETHODIMP CRegistrySource::QueryValueDword ( PCWSTR  keyName,
PCWSTR  valueName,
DWORD pdwValue 
)
override

Definition at line 377 of file querysrc.cpp.

378{
379 DWORD dwType, cbValue = sizeof(*pdwValue);
380 LSTATUS error = SHGetValueW(m_hKey, keyName, valueName, &dwType, pdwValue, &cbValue);
381 if (error)
383 if (dwType != REG_DWORD)
384 return E_DATATYPE_MISMATCH;
385 return S_OK;
386}
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1278
#define REG_DWORD
Definition: sdbapi.c:615
#define E_DATATYPE_MISMATCH

◆ QueryValueExists()

STDMETHODIMP CRegistrySource::QueryValueExists ( PCWSTR  keyName,
PCWSTR  valueName 
)
override

Definition at line 388 of file querysrc.cpp.

389{
390 LSTATUS error = SHGetValueW(m_hKey, keyName, valueName, NULL, NULL, NULL);
391 if (error)
393 return S_OK;
394}

◆ QueryValueString()

STDMETHODIMP CRegistrySource::QueryValueString ( PCWSTR  keyName,
PCWSTR  valueName,
PWSTR ppszValue 
)
override

Definition at line 332 of file querysrc.cpp.

336{
337 *ppszValue = NULL;
338
339 WCHAR szData[128];
340 DWORD dwType = REG_NONE, cbData = sizeof(szData);
341 LSTATUS error = SHGetValueW(m_hKey, keyName, valueName, &dwType, szData, &cbData);
342 if (error == ERROR_SUCCESS)
343 {
344 if (dwType != REG_SZ)
345 return E_DATATYPE_MISMATCH;
346 if (!valueName && !szData[0])
348 return SHStrDupW(szData, ppszValue);
349 }
350
351 if (error != ERROR_MORE_DATA)
353
354 *ppszValue = (PWSTR)CoTaskMemAlloc(cbData);
355 if (!*ppszValue)
356 return E_OUTOFMEMORY;
357
358 HRESULT hr = S_OK;
359 error = SHGetValueW(m_hKey, keyName, valueName, &dwType, *ppszValue, &cbData);
360 if (error)
361 {
362 CoTaskMemFree(*ppszValue);
363 *ppszValue = NULL;
365 }
366
367 if (SUCCEEDED(hr) && dwType != REG_SZ)
368 {
369 CoTaskMemFree(*ppszValue);
370 *ppszValue = NULL;
372 }
373
374 return hr;
375}
HRESULT WINAPI SHStrDupW(LPCWSTR src, LPWSTR *dest)
Definition: string.c:2148
#define REG_SZ
Definition: layer.c:22
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
short WCHAR
Definition: pedump.c:58
uint16_t * PWSTR
Definition: typedefs.h:56

◆ SetKey()

STDMETHODIMP CRegistrySource::SetKey ( HKEY  hKey)
override

Definition at line 466 of file querysrc.cpp.

467{
468 if (m_hKey)
469 return E_UNEXPECTED;
470
472 return m_hKey ? S_OK : E_UNEXPECTED;
473}

◆ SetValueDirect()

STDMETHODIMP CRegistrySource::SetValueDirect ( PCWSTR  keyName,
PCWSTR  valueName,
DWORD  dwType,
DWORD  cbData,
LPCVOID  pvData 
)
override

Definition at line 453 of file querysrc.cpp.

459{
460 LSTATUS error = SHSetValueW(m_hKey, keyName, valueName, dwType, pvData, cbData);
461 if (error)
463 return S_OK;
464}
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1348
_In_ LPWSTR _In_ DWORD _In_ LPCVOID pvData
Definition: netsh.h:116

◆ STDMETHODIMP_() [1/2]

CRegistrySource::STDMETHODIMP_ ( ULONG  )
override

◆ STDMETHODIMP_() [2/2]

CRegistrySource::STDMETHODIMP_ ( ULONG  )
override

Member Data Documentation

◆ m_cRefs

LONG CRegistrySource::m_cRefs = 1
private

Definition at line 94 of file querysrc.cpp.

◆ m_hKey


The documentation for this class was generated from the following file: