diff --git a/src/libi18n/i18n.c b/src/libi18n/i18n.c index 00c4ce3e72..02337f4e03 100644 --- a/src/libi18n/i18n.c +++ b/src/libi18n/i18n.c @@ -63,7 +63,7 @@ static void rp_i18n_init_int(void) // Get the current module filename. // NOTE: Delay-load only supports ANSI module names. // We'll assume it's ASCII and do a simple conversion to Unicode. - SetLastError(ERROR_SUCCESS); + SetLastError(ERROR_SUCCESS); // required for XP dwResult = GetModuleFileName(HINST_THISCOMPONENT, tpathname, ARRAY_SIZE(tpathname)); if (dwResult == 0 || GetLastError() != ERROR_SUCCESS) { diff --git a/src/libromdata/data/AmiiboData.cpp b/src/libromdata/data/AmiiboData.cpp index f060e332a9..699bf826d2 100644 --- a/src/libromdata/data/AmiiboData.cpp +++ b/src/libromdata/data/AmiiboData.cpp @@ -194,6 +194,7 @@ string AmiiboDataPrivate::getAmiiboBinFilename(AmiiboBinFileType amiiboBinFileTy filename = DIR_INSTALL_SHARE DIR_SEP_STR AMIIBO_BIN_FILENAME; #elif defined(_WIN32) TCHAR dll_filename[MAX_PATH]; + SetLastError(ERROR_SUCCESS); // required for XP DWORD dwResult = GetModuleFileName(HINST_THISCOMPONENT, dll_filename, _countof(dll_filename)); if (dwResult == 0 || GetLastError() != ERROR_SUCCESS) { diff --git a/src/libromdata/img/ExecRpDownload_win32.cpp b/src/libromdata/img/ExecRpDownload_win32.cpp index 6aa522d953..a2e5853374 100644 --- a/src/libromdata/img/ExecRpDownload_win32.cpp +++ b/src/libromdata/img/ExecRpDownload_win32.cpp @@ -2,7 +2,7 @@ * ROM Properties Page shell extension. (libromdata) * * ExecRpDownload_win32.cpp: Execute rp-download.exe. (Win32) * * * - * Copyright (c) 2016-2020 by David Korth. * + * Copyright (c) 2016-2022 by David Korth. * * SPDX-License-Identifier: GPL-2.0-or-later * ***************************************************************************/ @@ -32,6 +32,7 @@ int CacheManager::execRpDownload(const string &filteredCacheKey) { // The executable should be located in the DLL directory. TCHAR dll_filename[MAX_PATH]; + SetLastError(ERROR_SUCCESS); // required for XP DWORD dwResult = GetModuleFileName(HINST_THISCOMPONENT, dll_filename, _countof(dll_filename)); if (dwResult == 0 || GetLastError() != ERROR_SUCCESS) { diff --git a/src/libwin32common/DelayLoadHelper.c b/src/libwin32common/DelayLoadHelper.c index 8eda5b56a7..1afca23346 100644 --- a/src/libwin32common/DelayLoadHelper.c +++ b/src/libwin32common/DelayLoadHelper.c @@ -105,7 +105,7 @@ static HMODULE WINAPI rp_loadLibrary(LPCSTR pszModuleName) // NOTE: Delay-load only supports ANSI module names. // We'll assume it's ASCII and do a simple conversion to Unicode. - SetLastError(ERROR_SUCCESS); + SetLastError(ERROR_SUCCESS); // required for XP dwResult = GetModuleFileName(HINST_THISCOMPONENT, dll_fullpath, _countof(dll_fullpath)); if (dwResult == 0 || GetLastError() != ERROR_SUCCESS) { diff --git a/src/libwin32common/RegKey.cpp b/src/libwin32common/RegKey.cpp index 8948dbb9e7..86f18a1286 100644 --- a/src/libwin32common/RegKey.cpp +++ b/src/libwin32common/RegKey.cpp @@ -669,6 +669,7 @@ LONG RegKey::RegisterComObject(HINSTANCE hInstance, REFCLSID rclsid, // Set the default value to the filename of the specified DLL. // TODO: Duplicated from win32/. Consolidate the two? TCHAR dll_filename[MAX_PATH]; + SetLastError(ERROR_SUCCESS); // required for XP DWORD dwResult = GetModuleFileName(hInstance, dll_filename, _countof(dll_filename)); if (dwResult == 0 || GetLastError() != ERROR_SUCCESS) { // Cannot get the DLL filename. diff --git a/src/svrplus/svrplus.c b/src/svrplus/svrplus.c index c2c6e551d4..0c5e52836e 100644 --- a/src/svrplus/svrplus.c +++ b/src/svrplus/svrplus.c @@ -287,6 +287,7 @@ static InstallServerResult InstallServer(bool isUninstall, bool is64, DWORD *pEr // Construct arguments // Construct path to rom-properties.dll inside the arguments + SetLastError(ERROR_SUCCESS); // required for XP szModuleFn = GetModuleFileName(HINST_THISCOMPONENT, &args[14], MAX_PATH); assert(szModuleFn != 0); assert(szModuleFn < MAX_PATH); diff --git a/src/win32/DllMain.cpp b/src/win32/DllMain.cpp index 8b73b904c2..490aec7a9a 100644 --- a/src/win32/DllMain.cpp +++ b/src/win32/DllMain.cpp @@ -71,7 +71,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) switch (dwReason) { case DLL_PROCESS_ATTACH: { // Get the DLL filename. - SetLastError(ERROR_SUCCESS); + SetLastError(ERROR_SUCCESS); // required for XP DWORD dwResult = GetModuleFileName(hInstance, dll_filename, _countof(dll_filename)); if (dwResult == 0 || GetLastError() != ERROR_SUCCESS) { diff --git a/src/win32/config/rp-config.c b/src/win32/config/rp-config.c index 5cc0b7eeca..175d446d8c 100644 --- a/src/win32/config/rp-config.c +++ b/src/win32/config/rp-config.c @@ -153,6 +153,7 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, exe_path = malloc(MAX_PATH*sizeof(TCHAR)); if (!exe_path) FAIL_MESSAGE(_T("Failed to allocate memory for the EXE path.")); + SetLastError(ERROR_SUCCESS); // required for XP exe_path_len = GetModuleFileName(hInstance, exe_path, EXE_PATH_LEN); if (exe_path_len == 0 || exe_path_len >= EXE_PATH_LEN) FAIL_MESSAGE(_T("Failed to get the EXE path."));