mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Merging PR #2057 caused the Windows build to fail: shell_integration\windows\OCUtil\RegistryUtil.cpp(43): error C2664: 'LSTATUS RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY)': cannot convert argument 3 from 'nullptr' to 'DWORD' The previous implementation prior the PR supplied NULL as the argument 3 to RegOpenKeyEx, so it was silently accepted and translated to zero, satisfying the DWORD's type requirement. Signed-off-by: Michael Schuster <michael@schuster.ms>
71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
/**
|
|
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
|
|
*
|
|
* This library is free software; you can redistribute it and/or modify it under
|
|
* the terms of the GNU Lesser General Public License as published by the Free
|
|
* Software Foundation; either version 2.1 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
|
* details.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "RegistryUtil.h"
|
|
|
|
using namespace std;
|
|
|
|
#define SIZE 4096
|
|
|
|
bool RegistryUtil::ReadRegistry(const wchar_t* key, const wchar_t* name, int* result)
|
|
{
|
|
wstring* strResult = new wstring();
|
|
|
|
if(!ReadRegistry(key, name, strResult))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
*result = stoi( strResult->c_str() );
|
|
|
|
return true;
|
|
}
|
|
|
|
bool RegistryUtil::ReadRegistry(const wchar_t* key, const wchar_t* name, wstring* result)
|
|
{
|
|
HRESULT hResult;
|
|
|
|
HKEY rootKey = nullptr;
|
|
|
|
hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CURRENT_USER, (LPCWSTR)key, 0, KEY_READ, &rootKey));
|
|
|
|
if(!SUCCEEDED(hResult))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
wchar_t value[SIZE];
|
|
DWORD value_length = SIZE;
|
|
|
|
hResult = RegQueryValueEx(rootKey, (LPCWSTR)name, nullptr, nullptr, (LPBYTE)value, &value_length );
|
|
|
|
if(!SUCCEEDED(hResult))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
result->append(value);
|
|
|
|
HRESULT hResult2 = RegCloseKey(rootKey);
|
|
|
|
if (!SUCCEEDED(hResult2))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|