diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 40f6e0b9..f76aa3c8 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -60,7 +60,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Configuration/PropertySheet.h" #include "Tfe/Tfe.h" -#define VERSIONSTRING_SIZE 16 +static const UINT VERSIONSTRING_SIZE = 16; static UINT16 g_AppleWinVersion[4] = {0}; static UINT16 g_OldAppleWinVersion[4] = {0}; @@ -545,8 +545,8 @@ void LoadConfiguration(void) if (dwLoadedComputerType != dwComputerType) { - char sText[ 100 ]; - _snprintf( sText, sizeof(sText)-1, "Unsupported Apple2Type(%d). Changing to %d", dwLoadedComputerType, dwComputerType); + char sText[100]; + StringCbPrintf(sText, sizeof(sText), "Unsupported Apple2Type(%d). Changing to %d", dwLoadedComputerType, dwComputerType); LogFileOutput("%s\n", sText); diff --git a/source/Configuration/PageDisk.cpp b/source/Configuration/PageDisk.cpp index c8d3e9ac..99ec51be 100644 --- a/source/Configuration/PageDisk.cpp +++ b/source/Configuration/PageDisk.cpp @@ -363,20 +363,17 @@ void CPageDisk::HandleHDDSwap(HWND hWnd) UINT CPageDisk::RemovalConfirmation(UINT uCommand) { TCHAR szText[100]; - const size_t strLen = sizeof(szText)-1; bool bMsgBox = true; if (uCommand == IDC_COMBO_DISK1 || uCommand == IDC_COMBO_DISK2) - _snprintf(szText, strLen, "Do you really want to eject the disk in drive-%c ?", '1' + uCommand - IDC_COMBO_DISK1); + StringCbPrintf(szText, sizeof(szText), "Do you really want to eject the disk in drive-%c ?", '1' + uCommand - IDC_COMBO_DISK1); else if (uCommand == IDC_COMBO_HDD1 || uCommand == IDC_COMBO_HDD2) - _snprintf(szText, strLen, "Do you really want to unplug harddisk-%c ?", '1' + uCommand - IDC_COMBO_HDD1); + StringCbPrintf(szText, sizeof(szText), "Do you really want to unplug harddisk-%c ?", '1' + uCommand - IDC_COMBO_HDD1); else if (uCommand == IDC_HDD_SWAP) - _snprintf(szText, strLen, "Do you really want to swap the harddisk images?"); + StringCbPrintf(szText, sizeof(szText), "Do you really want to swap the harddisk images?"); else bMsgBox = false; - szText[strLen] = 0; - if (bMsgBox) { int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Eject/Unplug Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); diff --git a/source/Disk.cpp b/source/Disk.cpp index 864843b6..0acd949f 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -638,8 +638,7 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil if (Error == eIMAGE_ERROR_NONE && ImageIsMultiFileZip(pFloppy->m_imagehandle)) { TCHAR szText[100+MAX_PATH]; - szText[sizeof(szText)-1] = 0; - _snprintf(szText, sizeof(szText)-1, "Only the first file in a multi-file zip is supported\nUse disk image '%s' ?", pFloppy->m_strFilenameInZip.c_str()); + StringCbPrintf(szText, sizeof(szText), "Only the first file in a multi-file zip is supported\nUse disk image '%s' ?", pFloppy->m_strFilenameInZip.c_str()); int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Multi-Zip Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); if (nRes == IDNO) { diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index 74c28f27..4c2b50d0 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -413,17 +413,16 @@ BOOL HD_Insert(const int iDrive, LPCTSTR pszImageFilename) return g_HardDisk[iDrive].hd_imageloaded; } -static bool HD_SelectImage(const int iDrive, LPCSTR pszFilename) +static bool HD_SelectImage(const int drive, LPCSTR pszFilename) { TCHAR directory[MAX_PATH]; TCHAR filename[MAX_PATH]; TCHAR title[40]; - strcpy(filename, pszFilename); + StringCbCopy(filename, MAX_PATH, pszFilename); RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_HDV_START_DIR), 1, directory, MAX_PATH, TEXT("")); - _tcscpy(title, TEXT("Select HDV Image For HDD ")); - _tcscat(title, iDrive ? TEXT("2") : TEXT("1")); + StringCbPrintf(title, 40, TEXT("Select HDV Image For HDD %d"), drive + 1); _ASSERT(sizeof(OPENFILENAME) == sizeof(OPENFILENAME_NT4)); // Required for Win98/ME support (selected by _WIN32_WINNT=0x0400 in stdafx.h) @@ -445,9 +444,9 @@ static bool HD_SelectImage(const int iDrive, LPCSTR pszFilename) if (GetOpenFileName(&ofn)) { if ((!ofn.nFileExtension) || !filename[ofn.nFileExtension]) - _tcscat(filename,TEXT(".hdv")); + StringCbCat(filename, MAX_PATH, TEXT(".hdv")); - if (HD_Insert(iDrive, filename)) + if (HD_Insert(drive, filename)) { bRes = true; } diff --git a/source/Memory.cpp b/source/Memory.cpp index da593286..95df5dce 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -1528,7 +1528,7 @@ void MemInitializeROM(void) } TCHAR sText[MAX_PATH]; - _snprintf(sText, sizeof(sText)-1, TEXT("Unable to open the required firmware ROM data file.\n\nFile: %s"), sRomFileName); + StringCbPrintf(sText, sizeof(sText), TEXT("Unable to open the required firmware ROM data file.\n\nFile: %s"), sRomFileName); LogFileOutput("%s\n", sText);