diff options
author | Jose <jose@zeroc.com> | 2018-09-04 18:20:16 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2018-09-04 18:28:45 +0200 |
commit | 17c4cd26954259b12c2fa2d03bcc5738875735f2 (patch) | |
tree | 22f2acd1ad3f3eb091ca01153b7001843778b6c0 /cpp/src | |
parent | MATLAB UnsupportedProtocolException missing "reason" member (diff) | |
download | ice-17c4cd26954259b12c2fa2d03bcc5738875735f2.tar.bz2 ice-17c4cd26954259b12c2fa2d03bcc5738875735f2.tar.xz ice-17c4cd26954259b12c2fa2d03bcc5738875735f2.zip |
Add support for read properties from HKCU windows registry
It was possible before to read Ice properties from HKLM Windows
this fix alows to also read properties from HKCU
Close #130
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 3253b4ab183..2cf5b810f0a 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -298,15 +298,16 @@ Ice::PropertiesI::load(const std::string& file) StringConverterPtr stringConverter = getProcessStringConverter(); // -// Metro style applications cannot access Windows registry. +// UWP applications cannot access Windows registry. // #if defined (_WIN32) && !defined(ICE_OS_UWP) - if(file.find("HKLM\\") == 0) + if(file.find("HKCU\\") == 0 || file.find("HKLM\\") == 0) { + HKEY key = file.find("HKCU\\") == 0 ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; HKEY iceKey; - const wstring keyName = stringToWstring(file, stringConverter).substr(5).c_str(); + const wstring keyName = stringToWstring(file, stringConverter).substr(file.find("\\") + 1).c_str(); LONG err; - if((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName.c_str(), 0, KEY_QUERY_VALUE, &iceKey)) != ERROR_SUCCESS) + if((err = RegOpenKeyExW(key, keyName.c_str(), 0, KEY_QUERY_VALUE, &iceKey)) != ERROR_SUCCESS) { throw InitializationException(__FILE__, __LINE__, "could not open Windows registry key `" + file + "':\n" + IceUtilInternal::errorToString(err)); @@ -317,12 +318,12 @@ Ice::PropertiesI::load(const std::string& file) DWORD numValues; try { - err = RegQueryInfoKey(iceKey, ICE_NULLPTR, ICE_NULLPTR, ICE_NULLPTR, ICE_NULLPTR, ICE_NULLPTR, ICE_NULLPTR, &numValues, &maxNameSize, &maxDataSize, - ICE_NULLPTR, ICE_NULLPTR); + err = RegQueryInfoKey(iceKey, ICE_NULLPTR, ICE_NULLPTR, ICE_NULLPTR, ICE_NULLPTR, ICE_NULLPTR, ICE_NULLPTR, + &numValues, &maxNameSize, &maxDataSize, ICE_NULLPTR, ICE_NULLPTR); if(err != ERROR_SUCCESS) { - throw InitializationException(__FILE__, __LINE__, "could not open Windows registry key `" + file + "':\n" + - IceUtilInternal::errorToString(err)); + throw InitializationException(__FILE__, __LINE__, "could not open Windows registry key `" + file + + "':\n" + IceUtilInternal::errorToString(err)); } for(DWORD i = 0; i < numValues; ++i) |