Replace StringCbPrintf() with StrFormat() (PR #1032)

This commit is contained in:
Kelvin Lee
2022-02-16 05:48:20 +11:00
committed by GitHub
parent 48dd638d33
commit 1a4e933778
16 changed files with 103 additions and 147 deletions
+9 -12
View File
@@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Registry.h"
#include "CmdLine.h"
#include "StrFormat.h"
namespace _ini {
//===========================================================================
@@ -60,14 +61,13 @@ BOOL RegLoadString (LPCTSTR section, LPCTSTR key, BOOL peruser, LPTSTR buffer, D
if (!g_sConfigFile.empty())
return _ini::RegLoadString(section, key, peruser, buffer, chars);
TCHAR fullkeyname[256];
StringCbPrintf(fullkeyname, 256, TEXT("Software\\AppleWin\\CurrentVersion\\%s"), section);
std::string fullkeyname = std::string("Software\\AppleWin\\CurrentVersion\\") + section;
BOOL success = FALSE;
HKEY keyhandle;
LSTATUS status = RegOpenKeyEx(
(peruser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE),
fullkeyname,
fullkeyname.c_str(),
0,
KEY_READ,
&keyhandle);
@@ -119,14 +119,13 @@ void RegSaveString (LPCTSTR section, LPCTSTR key, BOOL peruser, const std::strin
if (!g_sConfigFile.empty())
return _ini::RegSaveString(section, key, peruser, buffer);
TCHAR fullkeyname[256];
StringCbPrintf(fullkeyname, 256, TEXT("Software\\AppleWin\\CurrentVersion\\%s"), section);
std::string fullkeyname = std::string("Software\\AppleWin\\CurrentVersion\\") + section;
HKEY keyhandle;
DWORD disposition;
LSTATUS status = RegCreateKeyEx(
(peruser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE),
fullkeyname,
fullkeyname.c_str(),
0,
NULL,
REG_OPTION_NON_VOLATILE,
@@ -149,9 +148,8 @@ void RegSaveString (LPCTSTR section, LPCTSTR key, BOOL peruser, const std::strin
//===========================================================================
void RegSaveValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD value) {
TCHAR buffer[32] = TEXT("");
StringCbPrintf(buffer, 32, "%d", value);
RegSaveString(section, key, peruser, buffer);
std::string strValue = StrFormat("%d", value);
RegSaveString(section, key, peruser, strValue.c_str());
}
//===========================================================================
@@ -188,13 +186,12 @@ void RegDeleteConfigSlotSection(UINT slot)
return _ini::RegDeleteString(section.c_str(), peruser);
}
TCHAR fullkeyname[256];
StringCbPrintf(fullkeyname, 256, TEXT("Software\\AppleWin\\CurrentVersion\\%s"), REG_CONFIG);
std::string fullkeyname = std::string("Software\\AppleWin\\CurrentVersion\\") + REG_CONFIG;
HKEY keyhandle;
LSTATUS status = RegOpenKeyEx(
(peruser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE),
fullkeyname,
fullkeyname.c_str(),
0,
KEY_READ,
&keyhandle);