mirror of
https://github.com/reactos/reactos.git
synced 2024-10-05 08:54:40 +00:00
implemented ExpandEnvironmentStringsForUserA/W
svn path=/trunk/; revision=20612
This commit is contained in:
parent
a56d746326
commit
59921c5d0a
|
@ -394,4 +394,126 @@ DestroyEnvironmentBlock (LPVOID lpEnvironment)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
ExpandEnvironmentStringsForUserW(IN HANDLE hToken,
|
||||
IN LPCWSTR lpSrc,
|
||||
OUT LPWSTR lpDest,
|
||||
IN DWORD dwSize)
|
||||
{
|
||||
PVOID lpEnvironment;
|
||||
BOOL Ret = FALSE;
|
||||
|
||||
if (lpSrc == NULL || lpDest == NULL || dwSize == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (CreateEnvironmentBlock(&lpEnvironment,
|
||||
hToken,
|
||||
FALSE))
|
||||
{
|
||||
UNICODE_STRING SrcU, DestU;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* initialize the strings */
|
||||
RtlInitUnicodeString(&SrcU,
|
||||
lpSrc);
|
||||
DestU.Length = 0;
|
||||
DestU.MaximumLength = dwSize * sizeof(WCHAR);
|
||||
DestU.Buffer = lpDest;
|
||||
|
||||
/* expand the strings */
|
||||
Status = RtlExpandEnvironmentStrings_U((PWSTR)lpEnvironment,
|
||||
&SrcU,
|
||||
&DestU,
|
||||
NULL);
|
||||
|
||||
DestroyEnvironmentBlock(lpEnvironment);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Ret = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
}
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
ExpandEnvironmentStringsForUserA(IN HANDLE hToken,
|
||||
IN LPCSTR lpSrc,
|
||||
OUT LPSTR lpDest,
|
||||
IN DWORD dwSize)
|
||||
{
|
||||
DWORD dwSrcLen;
|
||||
LPWSTR lpSrcW = NULL, lpDestW = NULL;
|
||||
BOOL Ret = FALSE;
|
||||
|
||||
if (lpSrc == NULL || lpDest == NULL || dwSize == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dwSrcLen = strlen(lpSrc);
|
||||
lpSrcW = (LPWSTR)GlobalAlloc(GMEM_FIXED,
|
||||
(dwSrcLen + 1) * sizeof(WCHAR));
|
||||
if (lpSrcW == NULL ||
|
||||
MultiByteToWideChar(CP_ACP,
|
||||
0,
|
||||
lpSrc,
|
||||
-1,
|
||||
lpSrcW,
|
||||
dwSrcLen + 1) == 0)
|
||||
{
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
lpDestW = (LPWSTR)GlobalAlloc(GMEM_FIXED,
|
||||
dwSize * sizeof(WCHAR));
|
||||
if (lpDestW == NULL)
|
||||
{
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
Ret = ExpandEnvironmentStringsForUserW(hToken,
|
||||
lpSrcW,
|
||||
lpDestW,
|
||||
dwSize);
|
||||
if (Ret)
|
||||
{
|
||||
if (WideCharToMultiByte(CP_ACP,
|
||||
0,
|
||||
lpDestW,
|
||||
-1,
|
||||
lpDest,
|
||||
dwSize,
|
||||
NULL,
|
||||
NULL) == 0)
|
||||
{
|
||||
Ret = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
if (lpSrcW != NULL)
|
||||
{
|
||||
GlobalFree((HGLOBAL)lpSrcW);
|
||||
}
|
||||
|
||||
if (lpDestW != NULL)
|
||||
{
|
||||
GlobalFree((HGLOBAL)lpDestW);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -19,6 +19,8 @@ DeleteDesktopItemA@8 @115 NONAME
|
|||
DeleteDesktopItemW@8 @116 NONAME
|
||||
CreateEnvironmentBlock@12
|
||||
DestroyEnvironmentBlock@4
|
||||
ExpandEnvironmentStringsForUserA@16
|
||||
ExpandEnvironmentStringsForUserW@16
|
||||
GetAllUsersProfileDirectoryA@8
|
||||
GetAllUsersProfileDirectoryW@8
|
||||
GetDefaultUserProfileDirectoryA@8
|
||||
|
|
Loading…
Reference in a new issue