#include "rapps.h"
-
BOOL
ShowAvailableAppInfo(INT Index)
{
WCHAR szSearchPath[MAX_PATH];
WCHAR szPath[MAX_PATH];
WCHAR szTmp[MAX_PATH];
+ HRESULT hr;
- if (!GetCurrentDirectoryW(MAX_PATH, szPath))
+ if (!GetStorageDirectory(szPath, sizeof(szPath) / sizeof(szPath[0])))
return FALSE;
- swprintf(szCabPath, L"%s\\rappmgr.cab", szPath);
+ hr = StringCbPrintfW(szCabPath, sizeof(szCabPath),
+ L"%ls\\rappmgr.cab",
+ szPath);
+ if (FAILED(hr))
+ return FALSE;
if (GetFileAttributesW(szCabPath) != INVALID_FILE_ATTRIBUTES)
{
return FALSE;
}
- wcscat(szPath, L"\\rapps\\");
- swprintf(szSearchPath, L"%s*.txt", szPath);
+ hr = StringCbCatW(szPath, sizeof(szPath), L"\\rapps\\");
+ if (FAILED(hr))
+ return FALSE;
+
+ hr = StringCbPrintfW(szSearchPath, sizeof(szSearchPath),
+ L"%ls*.txt",
+ szPath);
+ if (FAILED(hr))
+ return FALSE;
hFind = FindFirstFileW(szSearchPath, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
do
{
- swprintf(szTmp, L"%s%s", szPath, FindFileData.cFileName);
- if (!DeleteFileW(szTmp))
+ hr = StringCbPrintfW(szTmp, sizeof(szTmp),
+ L"%ls%ls",
+ szPath, FindFileData.cFileName);
+ if (FAILED(hr) || !DeleteFileW(szTmp))
{
FindClose(hFind);
return FALSE;
DownloadApplicationsDB(APPLICATION_DATEBASE_URL);
- if (!GetCurrentDirectoryW(MAX_PATH, szPath))
+ if (!GetStorageDirectory(szPath, sizeof(szPath) / sizeof(szPath[0])))
return FALSE;
- swprintf(szCabPath, L"%s\\rappmgr.cab", szPath);
+ if (FAILED(StringCbPrintfW(szCabPath, sizeof(szCabPath),
+ L"%ls\\rappmgr.cab",
+ szPath)))
+ {
+ return FALSE;
+ }
- wcscat(szPath, L"\\rapps\\");
- wcscpy(szAppsPath, szPath);
+ if (FAILED(StringCbPrintfW(szAppsPath, sizeof(szAppsPath),
+ L"%ls\\rapps\\",
+ szPath)))
+ {
+ return FALSE;
+ }
ExtractFilesFromCab(szCabPath, szAppsPath);
WCHAR szCabPath[MAX_PATH];
WCHAR szLocale[4 + 1];
APPLICATION_INFO Info;
+ HRESULT hr;
- if (!GetCurrentDirectoryW(MAX_PATH, szPath))
+ if (!GetStorageDirectory(szPath, sizeof(szPath) / sizeof(szPath[0])))
{
return FALSE;
}
- swprintf(szCabPath, L"%s\\rappmgr.cab", szPath);
+ hr = StringCbPrintfW(szCabPath, sizeof(szCabPath),
+ L"%ls\\rappmgr.cab",
+ szPath);
+ if (FAILED(hr))
+ return FALSE;
- wcscat(szPath, L"\\rapps\\");
- wcscpy(szAppsPath, szPath);
+ hr = StringCbCatW(szPath, sizeof(szPath), L"\\rapps\\");
+ if (FAILED(hr))
+ return FALSE;
+ hr = StringCbCopyW(szAppsPath, sizeof(szAppsPath), szPath);
+ if (FAILED(hr))
+ return FALSE;
if (!CreateDirectory(szPath, NULL) &&
GetLastError() != ERROR_ALREADY_EXISTS)
}
GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE, szLocale, sizeof(szLocale) / sizeof(WCHAR));
- wcscat(szSectionLocale, szLocale);
+ hr = StringCbCatW(szSectionLocale, sizeof(szSectionLocale), szLocale);
+ if (FAILED(hr))
+ return FALSE;
- wcscat(szPath, L"*.txt");
+ hr = StringCbCatW(szPath, sizeof(szPath), L"*.txt");
+ if (FAILED(hr))
+ return FALSE;
hFind = FindFirstFileW(szPath, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)