Commit b39c3981 authored by Vitaly Lipatov's avatar Vitaly Lipatov Committed by Alexandre Julliard

- Realize DoEnvironmentSubstA via ExpandEnvironmentStringsA.

- Fix types and return values. - Add prototype into shellapi.h.
parent 09b7503f
...@@ -1354,32 +1354,57 @@ HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z) ...@@ -1354,32 +1354,57 @@ HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
/************************************************************************ /************************************************************************
* DoEnvironmentSubstA [SHELL32.@] * DoEnvironmentSubstA [SHELL32.@]
* *
*/ * Replace %KEYWORD% in the str with the value of variable KEYWORD
HRESULT WINAPI DoEnvironmentSubstA(LPSTR x, LPSTR y) * from environment. If it is not found the %KEYWORD% is left
{ * intact. If the buffer is too small, str is not modified.
FIXME("(%s, %s) stub\n", debugstr_a(x), debugstr_a(y)); *
return 0; * pszString [I] '\0' terminated string with %keyword%.
* [O] '\0' terminated string with %keyword% substituted.
* cchString [I] size of str.
*
* Return
* cchString length in the HIWORD;
* TRUE in LOWORD if subst was successful and FALSE in other case
*/
DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
{
LPSTR dst;
BOOL res = FALSE;
FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
if (pszString == NULL) /* Really return 0? */
return 0;
if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
{
DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
if (num && num < cchString) /* dest buffer is too small */
{
res = TRUE;
memcpy(pszString, dst, num);
}
HeapFree(GetProcessHeap(), 0, dst);
}
return MAKELONG(res,cchString); /* Always cchString? */
} }
/************************************************************************ /************************************************************************
* DoEnvironmentSubstW [SHELL32.@] * DoEnvironmentSubstW [SHELL32.@]
* *
*/ */
HRESULT WINAPI DoEnvironmentSubstW(LPWSTR x, LPWSTR y) DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
{ {
FIXME("(%s, %s): stub\n", debugstr_w(x), debugstr_w(y)); FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
return 0; return MAKELONG(FALSE,cchString);
} }
/************************************************************************ /************************************************************************
* DoEnvironmentSubst [SHELL32.53] * DoEnvironmentSubst [SHELL32.53]
* *
*/ */
HRESULT WINAPI DoEnvironmentSubstAW(LPVOID x, LPVOID y) DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y)
{ {
if (SHELL_OsIsUnicode()) if (SHELL_OsIsUnicode())
return DoEnvironmentSubstW(x, y); return DoEnvironmentSubstW(x, y);
return DoEnvironmentSubstA(x, y); return DoEnvironmentSubstA(x, y);
} }
/************************************************************************* /*************************************************************************
......
...@@ -442,6 +442,10 @@ BOOL WINAPI ShellAboutW(HWND,LPCWSTR,LPCWSTR,HICON); ...@@ -442,6 +442,10 @@ BOOL WINAPI ShellAboutW(HWND,LPCWSTR,LPCWSTR,HICON);
int WINAPIV ShellMessageBoxA(HINSTANCE,HWND,LPCSTR,LPCSTR,UINT,...); int WINAPIV ShellMessageBoxA(HINSTANCE,HWND,LPCSTR,LPCSTR,UINT,...);
int WINAPIV ShellMessageBoxW(HINSTANCE,HWND,LPCWSTR,LPCWSTR,UINT,...); int WINAPIV ShellMessageBoxW(HINSTANCE,HWND,LPCWSTR,LPCWSTR,UINT,...);
#define ShellMessageBox WINELIB_NAME_AW(ShellMessageBox) #define ShellMessageBox WINELIB_NAME_AW(ShellMessageBox)
DWORD WINAPI DoEnvironmentSubstA(LPSTR, UINT);
DWORD WINAPI DoEnvironmentSubstW(LPWSTR, UINT);
#define DoEnvironmentSubst WINELIB_NAME_AW(DoEnvironmentSubst)
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment