Louis Lenders : shell32: Handle writing an iconresource entry in SHGetSetFolderCustomSettings.

Alexandre Julliard julliard at winehq.org
Mon Apr 30 15:12:47 CDT 2018


Module: wine
Branch: master
Commit: 730264609f468d7aa0973edc9a435bd20373c1cd
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=730264609f468d7aa0973edc9a435bd20373c1cd

Author: Louis Lenders <xerox.xerox2000x at gmail.com>
Date:   Mon Apr 30 09:22:42 2018 +0200

shell32: Handle writing an iconresource entry in SHGetSetFolderCustomSettings.

Signed-off-by: Louis Lenders <xerox.xerox2000x at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/shell32/shlfolder.c       | 38 ++++++++++++++++++++++++++++++++++----
 dlls/shell32/tests/shlfolder.c |  4 ++--
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/dlls/shell32/shlfolder.c b/dlls/shell32/shlfolder.c
index 9143f1e..a25ceae 100644
--- a/dlls/shell32/shlfolder.c
+++ b/dlls/shell32/shlfolder.c
@@ -605,14 +605,44 @@ HRESULT WINAPI SHOpenFolderAndSelectItems( PCIDLIST_ABSOLUTE pidlFolder, UINT ci
 }
 
 /***********************************************************************
- *  SHGetSetFolderCustomSettings
+ *  SHGetSetFolderCustomSettings (SHELL32.709)
  *
- *   Only Unicode above Server 2003
+ *   Only Unicode above Server 2003, writes/reads from a Desktop.ini
  */
 HRESULT WINAPI SHGetSetFolderCustomSettings( LPSHFOLDERCUSTOMSETTINGS fcs, PCWSTR path, DWORD flag )
 {
-    FIXME("%p %s 0x%x: stub\n", fcs, debugstr_w(path), flag);
-    return E_NOTIMPL;
+    static const WCHAR iconresourceW[] = {'I','c','o','n','R','e','s','o','u','r','c','e',0};
+    static const WCHAR desktop_iniW[] = {'D','e','s','k','t','o','p','.','i','n','i',0};
+    WCHAR bufferW[MAX_PATH];
+    HRESULT hr;
+
+    hr = E_FAIL;
+    bufferW[0] = 0;
+
+    if (!fcs || !path)
+        return hr;
+
+    if (flag & FCS_FORCEWRITE)
+    {
+        if (fcs->dwMask & FCSM_ICONFILE)
+        {
+            lstrcpyW(bufferW, path);
+            PathAddBackslashW(bufferW);
+            lstrcatW(bufferW, desktop_iniW);
+
+            if (WritePrivateProfileStringW(wszDotShellClassInfo, iconresourceW, fcs->pszIconFile, bufferW))
+            {
+                TRACE("Wrote an iconresource entry %s into %s\n", debugstr_w(fcs->pszIconFile), debugstr_w(bufferW));
+                hr = S_OK;
+            }
+            else
+                ERR("Failed to write (to) Desktop.ini file\n");
+        }
+    }
+    else
+        FIXME("%p %s 0x%x: stub\n", fcs, debugstr_w(path), flag);
+
+    return hr;
 }
 
 /***********************************************************************
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index 89a01b7..4ce9a4e 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -5278,7 +5278,7 @@ static void test_SHGetSetFolderCustomSettings(void)
     fcs.pszIconFile = iconpathW;
 
     hr = pSHGetSetFolderCustomSettings(&fcs, pathW, FCS_FORCEWRITE); /*creates and writes to a Desktop.ini*/
-    todo_wine ok(hr == S_OK, "Expected S_OK, got %#x\n", hr);
+    ok(hr == S_OK, "Expected S_OK, got %#x\n", hr);
 
     memset(&fcs, 0, sizeof(fcs));
     fcs.dwSize = sizeof(fcs);
@@ -5292,7 +5292,7 @@ static void test_SHGetSetFolderCustomSettings(void)
     todo_wine ok(!lstrcmpiW(iconpathW, fcs.pszIconFile), "Expected %s, got %s\n", wine_dbgstr_w(iconpathW), wine_dbgstr_w(fcs.pszIconFile));
 
     hr = pSHGetSetFolderCustomSettings(&fcs, NULL, FCS_READ);
-    todo_wine ok(hr == E_FAIL, "Expected E_FAIL, got %#x\n", hr);
+    ok(hr == E_FAIL, "Expected E_FAIL, got %#x\n", hr);
 
     lstrcpyW(bufferW, pathW);
     lstrcatW(bufferW, desktop_iniW);




More information about the wine-cvs mailing list