mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-31 16:04:27 +02:00
SF#3522081: WinRegistryConfiguration unable to read REG_QWORD values
This commit is contained in:
parent
2b2a362926
commit
71a055c81a
@ -33,6 +33,7 @@ Release 1.5.0 (2012-08-??)
|
|||||||
- fixed SF#3534307: Building IPv6 for Linux by default
|
- fixed SF#3534307: Building IPv6 for Linux by default
|
||||||
- fixed SF#3516844: poco missing symbols with external >=lipcre-8.13
|
- fixed SF#3516844: poco missing symbols with external >=lipcre-8.13
|
||||||
- added SF#3544720: AbstractConfigurator to support 64bit values
|
- added SF#3544720: AbstractConfigurator to support 64bit values
|
||||||
|
- fixed SF#3522081: WinRegistryConfiguration unable to read REG_QWORD values
|
||||||
|
|
||||||
Release 1.4.4 (2012-08-??)
|
Release 1.4.4 (2012-08-??)
|
||||||
==========================
|
==========================
|
||||||
|
@ -64,7 +64,8 @@ public:
|
|||||||
REGT_NONE = 0,
|
REGT_NONE = 0,
|
||||||
REGT_STRING = 1,
|
REGT_STRING = 1,
|
||||||
REGT_STRING_EXPAND = 2,
|
REGT_STRING_EXPAND = 2,
|
||||||
REGT_DWORD = 4
|
REGT_DWORD = 4,
|
||||||
|
REGT_QWORD = 11
|
||||||
};
|
};
|
||||||
|
|
||||||
WinRegistryKey(const std::string& key, bool readOnly = false, REGSAM extraSam = 0);
|
WinRegistryKey(const std::string& key, bool readOnly = false, REGSAM extraSam = 0);
|
||||||
@ -125,6 +126,16 @@ public:
|
|||||||
///
|
///
|
||||||
/// Throws a NotFoundException if the value does not exist.
|
/// Throws a NotFoundException if the value does not exist.
|
||||||
|
|
||||||
|
#if defined(POCO_HAVE_INT64)
|
||||||
|
|
||||||
|
Poco::Int64 getInt64(const std::string& name);
|
||||||
|
/// Returns the numeric value (REG_QWORD) with the given name.
|
||||||
|
/// An empty name denotes the default value.
|
||||||
|
///
|
||||||
|
/// Throws a NotFoundException if the value does not exist.
|
||||||
|
|
||||||
|
#endif // POCO_HAVE_INT64
|
||||||
|
|
||||||
void deleteValue(const std::string& name);
|
void deleteValue(const std::string& name);
|
||||||
/// Deletes the value with the given name.
|
/// Deletes the value with the given name.
|
||||||
///
|
///
|
||||||
|
@ -85,6 +85,9 @@ bool WinRegistryConfiguration::getRaw(const std::string& key, std::string& value
|
|||||||
case WinRegistryKey::REGT_DWORD:
|
case WinRegistryKey::REGT_DWORD:
|
||||||
value = Poco::NumberFormatter::format(aKey.getInt(keyName));
|
value = Poco::NumberFormatter::format(aKey.getInt(keyName));
|
||||||
break;
|
break;
|
||||||
|
case WinRegistryKey::REGT_QWORD:
|
||||||
|
value = Poco::NumberFormatter::format(aKey.getInt64(keyName));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
exists = false;
|
exists = false;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ void WinRegistryKey::setInt(const std::string& name, int value)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int WinRegistryKey::getInt(const std::string& name)
|
int WinRegistryKey::getInt(const std::string& name)
|
||||||
{
|
{
|
||||||
open();
|
open();
|
||||||
@ -266,6 +266,27 @@ int WinRegistryKey::getInt(const std::string& name)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(POCO_HAVE_INT64)
|
||||||
|
|
||||||
|
Poco::Int64 WinRegistryKey::getInt64(const std::string& name)
|
||||||
|
{
|
||||||
|
open();
|
||||||
|
DWORD type;
|
||||||
|
Poco::Int64 data;
|
||||||
|
DWORD size = sizeof(data);
|
||||||
|
#if defined(POCO_WIN32_UTF8)
|
||||||
|
std::wstring uname;
|
||||||
|
Poco::UnicodeConverter::toUTF16(name, uname);
|
||||||
|
if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || type != REG_DWORD)
|
||||||
|
throw NotFoundException(key(name));
|
||||||
|
#else
|
||||||
|
if (RegQueryValueExA(_hKey, name.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || type != REG_DWORD)
|
||||||
|
throw NotFoundException(key(name));
|
||||||
|
#endif
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // POCO_HAVE_INT64
|
||||||
|
|
||||||
void WinRegistryKey::deleteValue(const std::string& name)
|
void WinRegistryKey::deleteValue(const std::string& name)
|
||||||
{
|
{
|
||||||
|
@ -37,12 +37,18 @@
|
|||||||
#include "Poco/Util/WinRegistryKey.h"
|
#include "Poco/Util/WinRegistryKey.h"
|
||||||
#include "Poco/Environment.h"
|
#include "Poco/Environment.h"
|
||||||
#include "Poco/AutoPtr.h"
|
#include "Poco/AutoPtr.h"
|
||||||
|
#include "Poco/types.h"
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
|
||||||
using Poco::Util::WinRegistryConfiguration;
|
using Poco::Util::WinRegistryConfiguration;
|
||||||
using Poco::Util::WinRegistryKey;
|
using Poco::Util::WinRegistryKey;
|
||||||
using Poco::Environment;
|
using Poco::Environment;
|
||||||
using Poco::AutoPtr;
|
using Poco::AutoPtr;
|
||||||
|
using Poco::Int64;
|
||||||
|
using Poco::UInt64;
|
||||||
|
|
||||||
|
|
||||||
WinConfigurationTest::WinConfigurationTest(const std::string& name): CppUnit::TestCase(name)
|
WinConfigurationTest::WinConfigurationTest(const std::string& name): CppUnit::TestCase(name)
|
||||||
@ -68,6 +74,10 @@ void WinConfigurationTest::testConfiguration()
|
|||||||
assert (pReg->getInt("name1") == 1);
|
assert (pReg->getInt("name1") == 1);
|
||||||
pReg->setString("name2", "value2");
|
pReg->setString("name2", "value2");
|
||||||
assert (pReg->getString("name2") == "value2");
|
assert (pReg->getString("name2") == "value2");
|
||||||
|
pReg->setUInt64("name2", std::numeric_limits<UInt64>::max()); // overwrite should also change type
|
||||||
|
assert (pReg->getUInt64("name2") == std::numeric_limits<UInt64>::max());
|
||||||
|
pReg->setInt64("name2", std::numeric_limits<Int64>::min());
|
||||||
|
assert (pReg->getInt64("name2") == std::numeric_limits<Int64>::min());
|
||||||
assert (pReg->hasProperty("name1"));
|
assert (pReg->hasProperty("name1"));
|
||||||
assert (pReg->hasProperty("name2"));
|
assert (pReg->hasProperty("name2"));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user