https://git.reactos.org/?p=reactos.git;a=commitdiff;h=badcfb2f7dc84ed8c585d5be051bfe1f33f778fb

commit badcfb2f7dc84ed8c585d5be051bfe1f33f778fb
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Mon Apr 5 17:20:35 2021 +0900
Commit:     Katayama Hirofumi MZ <[email protected]>
CommitDate: Mon Apr 5 17:20:35 2021 +0900

    [BROWSEUI] Accept environment variables on auto-completion
    
    Expand %WINDIR%, %SystemRoot% etc. at CACListISF::Expand. CORE-9281
---
 dll/win32/browseui/aclistisf.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/dll/win32/browseui/aclistisf.cpp b/dll/win32/browseui/aclistisf.cpp
index 4e62b8a5e97..4ddeb8f2207 100644
--- a/dll/win32/browseui/aclistisf.cpp
+++ b/dll/win32/browseui/aclistisf.cpp
@@ -331,6 +331,14 @@ STDMETHODIMP CACListISF::Expand(LPCOLESTR pszExpand)
     m_szExpand = pszExpand;
     m_iNextLocation = LT_DIRECTORY;
 
+    // expand environment variables (%WINDIR% etc.)
+    WCHAR szExpanded[MAX_PATH];
+    if (wcschr(pszExpand, L'%') != NULL &&
+        ExpandEnvironmentStringsW(pszExpand, szExpanded, _countof(szExpanded)))
+    {
+        pszExpand = szExpanded;
+    }
+
     // get full path
     WCHAR szPath1[MAX_PATH], szPath2[MAX_PATH];
     if (PathIsRelativeW(pszExpand) &&
@@ -427,3 +435,4 @@ STDMETHODIMP CACListISF::SetDirectory(LPCWSTR pwzPath)
     m_pidlCurDir.Attach(pidl);
     return S_OK;
 }
+

Reply via email to