(Windows) Set the Registry functions to explicitly use the widestring variants

This commit is contained in:
Leon Styhre 2023-08-10 20:36:15 +02:00
parent 6c03688f8e
commit 3c9c031b1c

View file

@ -1731,13 +1731,13 @@ const std::string FileData::findEmulatorPath(std::string& command)
DWORD pathSize {1024};
// First look in HKEY_CURRENT_USER.
keyStatus = RegOpenKeyEx(HKEY_CURRENT_USER,
keyStatus = RegOpenKeyExW(HKEY_CURRENT_USER,
Utils::String::stringToWideString(registryKeyPath).c_str(), 0,
KEY_QUERY_VALUE, &registryKey);
// If not found, then try in HKEY_LOCAL_MACHINE.
if (keyStatus != ERROR_SUCCESS) {
keyStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
keyStatus = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
Utils::String::stringToWideString(registryKeyPath).c_str(), 0,
KEY_QUERY_VALUE, &registryKey);
}
@ -1792,20 +1792,20 @@ const std::string FileData::findEmulatorPath(std::string& command)
DWORD pathSize {1024};
// First look in HKEY_CURRENT_USER.
keyStatus = RegOpenKeyEx(HKEY_CURRENT_USER,
keyStatus = RegOpenKeyExW(HKEY_CURRENT_USER,
Utils::String::stringToWideString(registryValueKey).c_str(), 0,
KEY_QUERY_VALUE, &registryKey);
// If not found, then try in HKEY_LOCAL_MACHINE.
if (keyStatus != ERROR_SUCCESS) {
keyStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
Utils::String::stringToWideString(registryValueKey).c_str(), 0,
KEY_QUERY_VALUE, &registryKey);
keyStatus = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
Utils::String::stringToWideString(registryValueKey).c_str(),
0, KEY_QUERY_VALUE, &registryKey);
}
// If the key exists, then try to retrieve the defined value.
if (keyStatus == ERROR_SUCCESS) {
pathStatus = RegGetValue(registryKey, nullptr,
pathStatus = RegGetValueW(registryKey, nullptr,
Utils::String::stringToWideString(registryValue).c_str(),
RRF_RT_REG_SZ, nullptr, &path[0], &pathSize);
path.erase(std::find(path.begin(), path.end(), '\0'), path.end());