summaryrefslogtreecommitdiffstats
path: root/Source/cmExportCommand.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2013-12-05 05:17:24 (GMT)
committerBrad King <brad.king@kitware.com>2013-12-09 15:29:43 (GMT)
commit0b9906c2fba3fa7d2aebc5e217da31cd129b2bfc (patch)
tree512d1177b107bba94ddd7b016530f0c6a140b531 /Source/cmExportCommand.cxx
parentce598cc838c717132a122a97c5e21b99f11fe23b (diff)
downloadCMake-0b9906c2fba3fa7d2aebc5e217da31cd129b2bfc.zip
CMake-0b9906c2fba3fa7d2aebc5e217da31cd129b2bfc.tar.gz
CMake-0b9906c2fba3fa7d2aebc5e217da31cd129b2bfc.tar.bz2
Windows: Use wide-character system APIs
Make CMake compile with -DUNICODE. Make it possible for the 8 bit encoding to eventually be UTF-8 instead ANSI.
Diffstat (limited to 'Source/cmExportCommand.cxx')
-rw-r--r--Source/cmExportCommand.cxx19
1 files changed, 12 insertions, 7 deletions
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 3f6bc2e..0a67ccf 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -16,6 +16,7 @@
#include "cmake.h"
#include <cmsys/RegularExpression.hxx>
+#include <cmsys/Encoding.hxx>
#include "cmExportBuildFileGenerator.h"
@@ -252,14 +253,14 @@ void cmExportCommand::ReportRegistryError(std::string const& msg,
cmOStringStream e;
e << msg << "\n"
<< " HKEY_CURRENT_USER\\" << key << "\n";
- char winmsg[1024];
- if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+ wchar_t winmsg[1024];
+ if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, 0, err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
winmsg, 1024, 0) > 0)
{
e << "Windows reported:\n"
- << " " << winmsg;
+ << " " << cmsys::Encoding::ToNarrow(winmsg);
}
this->Makefile->IssueMessage(cmake::WARNING, e.str());
}
@@ -272,8 +273,9 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package,
std::string key = "Software\\Kitware\\CMake\\Packages\\";
key += package;
HKEY hKey;
- LONG err = RegCreateKeyEx(HKEY_CURRENT_USER,
- key.c_str(), 0, 0, REG_OPTION_NON_VOLATILE,
+ LONG err = RegCreateKeyExW(HKEY_CURRENT_USER,
+ cmsys::Encoding::ToWide(key).c_str(),
+ 0, 0, REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE, 0, &hKey, 0);
if(err != ERROR_SUCCESS)
{
@@ -281,8 +283,11 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package,
"Cannot create/open registry key", key, err);
return;
}
- err = RegSetValueEx(hKey, hash, 0, REG_SZ, (BYTE const*)content,
- static_cast<DWORD>(strlen(content)+1));
+
+ std::wstring wcontent = cmsys::Encoding::ToWide(content);
+ err = RegSetValueExW(hKey, cmsys::Encoding::ToWide(hash).c_str(),
+ 0, REG_SZ, (BYTE const*)wcontent.c_str(),
+ static_cast<DWORD>(wcontent.size()+1)*sizeof(wchar_t));
RegCloseKey(hKey);
if(err != ERROR_SUCCESS)
{