[PATCH 1/3] comdlg32: Expand initial directory path for file open dialog

Nikolay Sivov nsivov at codeweavers.com
Tue Feb 21 06:35:15 CST 2017


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

Based on patch by Kamil Hornicek

For https://bugs.winehq.org/show_bug.cgi?id=42469

 dlls/comdlg32/filedlg.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index 8dda4f7712..d76fad925a 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -504,15 +504,17 @@ static BOOL GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
   else
     fodInfos.filename = NULL;
 
+  fodInfos.initdir = NULL;
   if(ofn->lpstrInitialDir)
   {
     /* fodInfos.initdir = strdupW(ofn->lpstrInitialDir); */
-    DWORD len = lstrlenW(ofn->lpstrInitialDir)+1;
-    fodInfos.initdir = MemAlloc(len*sizeof(WCHAR));
-    memcpy(fodInfos.initdir,ofn->lpstrInitialDir,len*sizeof(WCHAR));
+    DWORD len = ExpandEnvironmentStringsW(ofn->lpstrInitialDir, NULL, 0);
+    if (len)
+    {
+      fodInfos.initdir = MemAlloc(len * sizeof(WCHAR));
+      ExpandEnvironmentStringsW(ofn->lpstrInitialDir, fodInfos.initdir, len);
+    }
   }
-  else
-    fodInfos.initdir = NULL;
 
   /* save current directory */
   if (ofn->Flags & OFN_NOCHANGEDIR)
-- 
2.11.0




More information about the wine-patches mailing list