1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-23 23:21:08 +01:00

Setup: Ensure file path for SHFileOperation is ended with 2 zeros

This commit is contained in:
Valentin Radu 2022-02-17 22:52:46 +02:00
parent 19ef6988b6
commit f34c6540a6

View File

@ -47,16 +47,18 @@ BOOL SetupShortcut(BOOL bInstall, WCHAR* wszPath, WCHAR* wszArguments)
}
}
BOOL bOk = FALSE;
WCHAR wszStartPrograms[MAX_PATH];
ZeroMemory(wszStartPrograms, MAX_PATH);
WCHAR wszStartPrograms[MAX_PATH + 1];
ZeroMemory(wszStartPrograms, MAX_PATH + 1);
SHGetFolderPathW(NULL, CSIDL_COMMON_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, wszStartPrograms);
wcscat_s(wszStartPrograms, MAX_PATH, L"\\" _T(PRODUCT_NAME));
wcscat_s(wszStartPrograms, MAX_PATH + 1, L"\\" _T(PRODUCT_NAME));
wszStartPrograms[wcslen(wszStartPrograms) + 1] = 0;
SHFILEOPSTRUCTW op;
ZeroMemory(&op, sizeof(SHFILEOPSTRUCTW));
op.wFunc = FO_DELETE;
op.pFrom = wszStartPrograms;
op.fFlags = FOF_NO_UI;
bOk = !SHFileOperationW(&op);
bOk = SHFileOperationW(&op);
bOk = !bOk;
if (bInstall)
{
if (!CreateDirectoryW(wszStartPrograms, NULL))