https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ce08851758fa938650fd3faae7d9b2ef499175e1
commit ce08851758fa938650fd3faae7d9b2ef499175e1 Author: Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org> AuthorDate: Thu Oct 5 22:41:16 2023 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org> CommitDate: Sat Oct 7 22:17:58 2023 +0200 [DESK] Use MultiByteToWideChar instead of the private pSetupMultiByteToUnicode function (#5765) This avoids having desk.cpl depend on a private function that may change or disappear, and increase the probability of being able to use that CPL across different Windows versions. (Note: this pSetupMultiByteToUnicode was one of those whose name changed between Windows 2000 and XP+) --- dll/cpl/desk/desk.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/dll/cpl/desk/desk.c b/dll/cpl/desk/desk.c index 7a34e2420b4..0bbfc7a4a0e 100644 --- a/dll/cpl/desk/desk.c +++ b/dll/cpl/desk/desk.c @@ -8,8 +8,11 @@ */ #include "desk.h" + #include <shellapi.h> #include <cplext.h> +#include <winnls.h> + #include <debug.h> #define NUM_APPLETS (1) @@ -364,6 +367,7 @@ InstallScreenSaverA( IN UINT nCmdShow) { LPWSTR lpwString; + int nLength; if (!pszFile) { @@ -371,16 +375,32 @@ InstallScreenSaverA( SetLastError(ERROR_INVALID_PARAMETER); return; } - DPRINT("InstallScreenSaver() Install from file %s\n", pszFile); - lpwString = pSetupMultiByteToUnicode(pszFile, 0); + + /* Convert the string to unicode */ + lpwString = NULL; + nLength = MultiByteToWideChar(CP_ACP, 0, pszFile, -1, NULL, 0); + if (nLength != 0) + { + lpwString = LocalAlloc(LMEM_FIXED, nLength * sizeof(WCHAR)); + if (lpwString) + { + if (!MultiByteToWideChar(CP_ACP, 0, pszFile, -1, lpwString, nLength)) + { + LocalFree(lpwString); + lpwString = NULL; + } + } + } if (!lpwString) { DPRINT("InstallScreenSaver() not enough memory to convert string to unicode\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); return; } + + /* Call the unicode function */ InstallScreenSaverW(hWindow, hInstance, lpwString, nCmdShow); - MyFree(lpwString); + + LocalFree(lpwString); } BOOL WINAPI