From 837c82d8b893804dc5242ecc378c6a228f883d03 Mon Sep 17 00:00:00 2001 From: Andrew Tonner Date: Wed, 12 Feb 2020 16:16:31 -0800 Subject: [PATCH] expect TCHAR returns from RegQueryValueEx now that we are potentially building with _UNICODE --- .../src/Windows/user_strings_windows.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/BasiliskII/src/Windows/user_strings_windows.cpp b/BasiliskII/src/Windows/user_strings_windows.cpp index 0d98d61f..dc2993da 100755 --- a/BasiliskII/src/Windows/user_strings_windows.cpp +++ b/BasiliskII/src/Windows/user_strings_windows.cpp @@ -20,7 +20,7 @@ #include "sysdeps.h" #include "user_strings.h" - +#include "util_windows.h" // Platform-specific string definitions user_string_def platform_strings[] = { @@ -81,7 +81,11 @@ static const char *get_volume_name(void) HKEY hHelpKey; DWORD key_type, cbData; - static char volume[256]; + #ifdef _UNICODE + static char out_volume[256]; + #endif + + static TCHAR volume[256]; memset(volume, 0, sizeof(volume)); // Try Windows 2000 key first @@ -118,14 +122,20 @@ static const char *get_volume_name(void) } // Fix the error that some "tweak" apps do. - if (_stricmp(volume, "%USERNAME% on %COMPUTER%") == 0) - volume[0] = '\0'; + if (_tcsicmp(volume, TEXT("%USERNAME% on %COMPUTER%")) == 0) + volume[0] = TEXT('\0'); // No volume name found, default to "My Computer" if (volume[0] == 0) - strcpy(volume, "My Computer"); + _tcscpy(volume, TEXT("My Computer")); + + #ifdef _UNICODE + strlcpy(out_volume, volume, 256); + return out_volume; + #else return volume; + #endif }