[PATCH 1/3] shell32: Implement DoEnvironmentSubstW
Detlef Riekenberg
wine.dev at web.de
Sat Nov 24 19:54:17 CST 2012
Needed for the ClassicShellMenu installer.
(Do not use DoEnvironmentSubstA as reference.
DoEnvironmentSubstA is broken.)
msdn:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb776405%28v=vs.85%29.aspx
--
By by ... Detlef
---
dlls/shell32/shellord.c | 41 +++++++++++++++++++++++++++++++++++++----
1 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index c1fb382..b71d213 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -1626,14 +1626,47 @@ DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
}
/************************************************************************
- * DoEnvironmentSubstW [SHELL32.@]
+ * DoEnvironmentSubstW [SHELL32.@]
*
- * See DoEnvironmentSubstA.
+ * Replace all %KEYWORD% in the string with the value of the named
+ * environment variable. If the buffer is too small, the string is not modified.
+ *
+ * PARAMS
+ * pszString [I] '\0' terminated string with %keyword%.
+ * [O] '\0' terminated string with %keyword% substituted.
+ * cchString [I] size of str.
+ *
+ * RETURNS
+ * Success: The string in the buffer is updated
+ * HIWORD: TRUE
+ * LOWORD: characters used in the buffer, including space for the terminating 0
+ * Failure: buffer too small. The string is not modified.
+ * HIWORD: FALSE
+ * LOWORD: provided size of the buffer in characters
*/
DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
{
- FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
- return MAKELONG(FALSE,cchString);
+ LPWSTR dst;
+ BOOL res = FALSE;
+ DWORD len = cchString;
+
+ TRACE("(%s, %d)\n", debugstr_w(pszString), cchString);
+
+ if ((cchString < MAXLONG) && (dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(WCHAR))))
+ {
+ len = ExpandEnvironmentStringsW(pszString, dst, cchString);
+ /* len includes the terminating 0 */
+ if (len && len <= cchString)
+ {
+ res = TRUE;
+ memcpy(pszString, dst, len * sizeof(WCHAR));
+ }
+ else
+ len = cchString;
+
+ HeapFree(GetProcessHeap(), 0, dst);
+ }
+ return MAKELONG(len, res);
}
/************************************************************************
--
1.7.5.4
More information about the wine-patches
mailing list