diff options
author | Brad King <brad.king@kitware.com> | 2008-05-27 18:47:00 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-05-27 18:47:00 (GMT) |
commit | cea66664c561796665bdf2ae74d4b20859f9667d (patch) | |
tree | 5e174c307e18950148d012124938c911607370ea /Source/kwsys/SystemTools.cxx | |
parent | 73d5fd31ab1fe62956b7f2ae8ffffeb3a7281708 (diff) | |
download | CMake-cea66664c561796665bdf2ae74d4b20859f9667d.zip CMake-cea66664c561796665bdf2ae74d4b20859f9667d.tar.gz CMake-cea66664c561796665bdf2ae74d4b20859f9667d.tar.bz2 |
ENH: Added WOW64 key view support to KWSys SystemTools' windows registry API.
- Add an argument to registry read/write/delete methods to specify
a 32-bit or 64-bit view.
- Default is the bit-ness of the running program.
- See issue #7095.
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index d5d530d..1277d71 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -493,6 +493,30 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, free(orig); } +#if defined(KEY_WOW64_32KEY) && defined(KEY_WOW64_64KEY) +# define KWSYS_ST_KEY_WOW64_32KEY KEY_WOW64_32KEY +# define KWSYS_ST_KEY_WOW64_64KEY KEY_WOW64_64KEY +#else +# define KWSYS_ST_KEY_WOW64_32KEY 0x0200 +# define KWSYS_ST_KEY_WOW64_64KEY 0x0100 +#endif + +#if defined(_WIN32) && !defined(__CYGWIN__) +static DWORD SystemToolsMakeRegistryMode(DWORD mode, + SystemTools::KeyWOW64 view) +{ + if(view == SystemTools::KeyWOW64_32) + { + return mode | KWSYS_ST_KEY_WOW64_32KEY; + } + else if(view == SystemTools::KeyWOW64_64) + { + return mode | KWSYS_ST_KEY_WOW64_64KEY; + } + return mode; +} +#endif + // Read a registry value. // Example : // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath @@ -501,7 +525,8 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, // => will return the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value) +bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, + KeyWOW64 view) { bool valueset = false; kwsys_stl::string primary = key; @@ -549,7 +574,7 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value) if(RegOpenKeyEx(primaryKey, second.c_str(), 0, - KEY_READ, + SystemToolsMakeRegistryMode(KEY_READ, view), &hKey) != ERROR_SUCCESS) { return false; @@ -589,7 +614,8 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value) return valueset; } #else -bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &) +bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &, + KeyWOW64) { return false; } @@ -604,7 +630,8 @@ bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &) // => will set the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::WriteRegistryValue(const char *key, const char *value) +bool SystemTools::WriteRegistryValue(const char *key, const char *value, + KeyWOW64 view) { kwsys_stl::string primary = key; kwsys_stl::string second; @@ -654,7 +681,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value) 0, "", REG_OPTION_NON_VOLATILE, - KEY_WRITE, + SystemToolsMakeRegistryMode(KEY_WRITE, view), NULL, &hKey, &dwDummy) != ERROR_SUCCESS) @@ -674,7 +701,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value) return false; } #else -bool SystemTools::WriteRegistryValue(const char *, const char *) +bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64) { return false; } @@ -688,7 +715,7 @@ bool SystemTools::WriteRegistryValue(const char *, const char *) // => will delete the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::DeleteRegistryValue(const char *key) +bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) { kwsys_stl::string primary = key; kwsys_stl::string second; @@ -735,7 +762,7 @@ bool SystemTools::DeleteRegistryValue(const char *key) if(RegOpenKeyEx(primaryKey, second.c_str(), 0, - KEY_WRITE, + SystemToolsMakeRegistryMode(KEY_WRITE, view), &hKey) != ERROR_SUCCESS) { return false; @@ -752,7 +779,7 @@ bool SystemTools::DeleteRegistryValue(const char *key) return false; } #else -bool SystemTools::DeleteRegistryValue(const char *) +bool SystemTools::DeleteRegistryValue(const char *, KeyWOW64) { return false; } |