mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[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+)
This commit is contained in:
parent
e4608f7450
commit
ce08851758
1 changed files with 24 additions and 4 deletions
|
@ -8,8 +8,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "desk.h"
|
#include "desk.h"
|
||||||
|
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <cplext.h>
|
#include <cplext.h>
|
||||||
|
#include <winnls.h>
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#define NUM_APPLETS (1)
|
#define NUM_APPLETS (1)
|
||||||
|
@ -364,6 +367,7 @@ InstallScreenSaverA(
|
||||||
IN UINT nCmdShow)
|
IN UINT nCmdShow)
|
||||||
{
|
{
|
||||||
LPWSTR lpwString;
|
LPWSTR lpwString;
|
||||||
|
int nLength;
|
||||||
|
|
||||||
if (!pszFile)
|
if (!pszFile)
|
||||||
{
|
{
|
||||||
|
@ -371,16 +375,32 @@ InstallScreenSaverA(
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return;
|
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)
|
if (!lpwString)
|
||||||
{
|
{
|
||||||
DPRINT("InstallScreenSaver() not enough memory to convert string to unicode\n");
|
DPRINT("InstallScreenSaver() not enough memory to convert string to unicode\n");
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Call the unicode function */
|
||||||
InstallScreenSaverW(hWindow, hInstance, lpwString, nCmdShow);
|
InstallScreenSaverW(hWindow, hInstance, lpwString, nCmdShow);
|
||||||
MyFree(lpwString);
|
|
||||||
|
LocalFree(lpwString);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
|
|
Loading…
Reference in a new issue