implemented ExpandEnvironmentStringsForUserA/W
Modified: trunk/reactos/lib/userenv/environment.c
Modified: trunk/reactos/lib/userenv/userenv.def
_____
Modified: trunk/reactos/lib/userenv/environment.c
--- trunk/reactos/lib/userenv/environment.c 2006-01-06 14:50:56 UTC
(rev 20611)
+++ trunk/reactos/lib/userenv/environment.c 2006-01-06 15:42:12 UTC
(rev 20612)
@@ -394,4 +394,126 @@
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 */
_____
Modified: trunk/reactos/lib/userenv/userenv.def
--- trunk/reactos/lib/userenv/userenv.def 2006-01-06 14:50:56 UTC
(rev 20611)
+++ trunk/reactos/lib/userenv/userenv.def 2006-01-06 15:42:12 UTC
(rev 20612)
@@ -19,6 +19,8 @@
DeleteDesktopItemW@8 @116 NONAME
CreateEnvironmentBlock@12
DestroyEnvironmentBlock@4
+ExpandEnvironmentStringsForUserA@16
+ExpandEnvironmentStringsForUserW@16
GetAllUsersProfileDirectoryA@8
GetAllUsersProfileDirectoryW@8
GetDefaultUserProfileDirectoryA@8
Show replies by date