diff options
Diffstat (limited to 'Source/cmGlobalVisualStudioGenerator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 7afcfa7..6c782e4 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -17,6 +17,7 @@ #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmTarget.h" +#include <cmsys/Encoding.hxx> //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() @@ -559,52 +560,53 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, keyname = regKeyBase + "\\OtherProjects7"; hkey = NULL; - result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), - 0, KEY_READ, &hkey); + result = RegOpenKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(keyname).c_str(), + 0, KEY_READ, &hkey); if (ERROR_SUCCESS == result) { // Iterate the subkeys and look for the values of interest in each subkey: - CHAR subkeyname[256]; - DWORD cch_subkeyname = sizeof(subkeyname)/sizeof(subkeyname[0]); - CHAR keyclass[256]; - DWORD cch_keyclass = sizeof(keyclass)/sizeof(keyclass[0]); + wchar_t subkeyname[256]; + DWORD cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]); + wchar_t keyclass[256]; + DWORD cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]); FILETIME lastWriteTime; lastWriteTime.dwHighDateTime = 0; lastWriteTime.dwLowDateTime = 0; - while (ERROR_SUCCESS == RegEnumKeyEx(hkey, index, subkeyname, + while (ERROR_SUCCESS == RegEnumKeyExW(hkey, index, subkeyname, &cch_subkeyname, 0, keyclass, &cch_keyclass, &lastWriteTime)) { // Open the subkey and query the values of interest: HKEY hsubkey = NULL; - result = RegOpenKeyEx(hkey, subkeyname, 0, KEY_READ, &hsubkey); + result = RegOpenKeyExW(hkey, subkeyname, 0, KEY_READ, &hsubkey); if (ERROR_SUCCESS == result) { DWORD valueType = REG_SZ; - CHAR data1[256]; - DWORD cch_data1 = sizeof(data1)/sizeof(data1[0]); - RegQueryValueEx(hsubkey, "Path", 0, &valueType, + wchar_t data1[256]; + DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]); + RegQueryValueExW(hsubkey, L"Path", 0, &valueType, (LPBYTE) &data1[0], &cch_data1); DWORD data2 = 0; DWORD cch_data2 = sizeof(data2); - RegQueryValueEx(hsubkey, "Security", 0, &valueType, + RegQueryValueExW(hsubkey, L"Security", 0, &valueType, (LPBYTE) &data2, &cch_data2); DWORD data3 = 0; DWORD cch_data3 = sizeof(data3); - RegQueryValueEx(hsubkey, "StorageFormat", 0, &valueType, + RegQueryValueExW(hsubkey, L"StorageFormat", 0, &valueType, (LPBYTE) &data3, &cch_data3); - s2 = cmSystemTools::LowerCase(data1); + s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1)); cmSystemTools::ConvertToUnixSlashes(s2); if (s2 == s1) { macrosRegistered = true; } - std::string fullname(data1); + std::string fullname = cmsys::Encoding::ToNarrow(data1); std::string filename; std::string filepath; std::string filepathname; @@ -636,8 +638,8 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, } ++index; - cch_subkeyname = sizeof(subkeyname)/sizeof(subkeyname[0]); - cch_keyclass = sizeof(keyclass)/sizeof(keyclass[0]); + cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]); + cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]); lastWriteTime.dwHighDateTime = 0; lastWriteTime.dwLowDateTime = 0; } @@ -662,27 +664,28 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, keyname = regKeyBase + "\\RecordingProject7"; hkey = NULL; - result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), - 0, KEY_READ, &hkey); + result = RegOpenKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(keyname).c_str(), + 0, KEY_READ, &hkey); if (ERROR_SUCCESS == result) { DWORD valueType = REG_SZ; - CHAR data1[256]; - DWORD cch_data1 = sizeof(data1)/sizeof(data1[0]); - RegQueryValueEx(hkey, "Path", 0, &valueType, + wchar_t data1[256]; + DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]); + RegQueryValueExW(hkey, L"Path", 0, &valueType, (LPBYTE) &data1[0], &cch_data1); DWORD data2 = 0; DWORD cch_data2 = sizeof(data2); - RegQueryValueEx(hkey, "Security", 0, &valueType, + RegQueryValueExW(hkey, L"Security", 0, &valueType, (LPBYTE) &data2, &cch_data2); DWORD data3 = 0; DWORD cch_data3 = sizeof(data3); - RegQueryValueEx(hkey, "StorageFormat", 0, &valueType, + RegQueryValueExW(hkey, L"StorageFormat", 0, &valueType, (LPBYTE) &data3, &cch_data3); - s2 = cmSystemTools::LowerCase(data1); + s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1)); cmSystemTools::ConvertToUnixSlashes(s2); if (s2 == s1) { @@ -714,24 +717,27 @@ void WriteVSMacrosFileRegistryEntry( { std::string keyname = regKeyBase + "\\OtherProjects7"; HKEY hkey = NULL; - LONG result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), 0, + LONG result = RegOpenKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(keyname).c_str(), 0, KEY_READ|KEY_WRITE, &hkey); if (ERROR_SUCCESS == result) { // Create the subkey and set the values of interest: HKEY hsubkey = NULL; - char lpClass[] = ""; - result = RegCreateKeyEx(hkey, nextAvailableSubKeyName.c_str(), 0, - lpClass, 0, KEY_READ|KEY_WRITE, 0, &hsubkey, 0); + wchar_t lpClass[] = L""; + result = RegCreateKeyExW(hkey, + cmsys::Encoding::ToWide(nextAvailableSubKeyName).c_str(), 0, + lpClass, 0, KEY_READ|KEY_WRITE, 0, &hsubkey, 0); if (ERROR_SUCCESS == result) { DWORD dw = 0; std::string s(macrosFile); cmSystemTools::ReplaceString(s, "/", "\\"); + std::wstring ws = cmsys::Encoding::ToWide(s); - result = RegSetValueEx(hsubkey, "Path", 0, REG_SZ, (LPBYTE) s.c_str(), - static_cast<DWORD>(strlen(s.c_str()) + 1)); + result = RegSetValueExW(hsubkey, L"Path", 0, REG_SZ, (LPBYTE)ws.c_str(), + static_cast<DWORD>(ws.size() + 1)*sizeof(wchar_t)); if (ERROR_SUCCESS != result) { std::cout << "error result 1: " << result << std::endl; @@ -741,7 +747,7 @@ void WriteVSMacrosFileRegistryEntry( // Security value is always "1" for sample macros files (seems to be "2" // if you put the file somewhere outside the standard VSMacros folder) dw = 1; - result = RegSetValueEx(hsubkey, "Security", + result = RegSetValueExW(hsubkey, L"Security", 0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD)); if (ERROR_SUCCESS != result) { @@ -751,7 +757,7 @@ void WriteVSMacrosFileRegistryEntry( // StorageFormat value is always "0" for sample macros files dw = 0; - result = RegSetValueEx(hsubkey, "StorageFormat", + result = RegSetValueExW(hsubkey, L"StorageFormat", 0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD)); if (ERROR_SUCCESS != result) { |