Write out icon file and icon index from in-memory shortcuts.

Andrew Bogott andrew at CodeWeavers.com
Fri Nov 19 22:02:26 CST 2010


Now that the shortcut implements IIPropertySetStorage, callers can
add properties to a shortcut; writing out these two properties
gets us closer to proper Steam game icons.
---
 dlls/shdocvw/intshcut.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/dlls/shdocvw/intshcut.c b/dlls/shdocvw/intshcut.c
index 8f55a20..8765d38 100644
--- a/dlls/shdocvw/intshcut.c
+++ b/dlls/shdocvw/intshcut.c
@@ -501,15 +501,56 @@ static HRESULT WINAPI PersistFile_Save(IPersistFile *pFile, LPCOLESTR pszFileNam
         if (file != INVALID_HANDLE_VALUE)
         {
             DWORD bytesWritten;
+            char *iconfile;
             char str_header[] = "[InternetShortcut]";
             char str_URL[] = "URL=";
+            char str_ICONFILE[] = "ICONFILE=";
             char str_eol[] = "\r\n";
+            IPropertyStorage *pPropStgRead;
+            PROPSPEC ps[2];
+            PROPVARIANT pvread[2];
+            ps[0].ulKind = PRSPEC_PROPID;
+            ps[0].propid = PID_IS_ICONFILE;
+            ps[1].ulKind = PRSPEC_PROPID;
+            ps[1].propid = PID_IS_ICONINDEX;
 
             WriteFile(file, str_header, lstrlenA(str_header), &bytesWritten, NULL);
             WriteFile(file, str_eol, lstrlenA(str_eol), &bytesWritten, NULL);
             WriteFile(file, str_URL, lstrlenA(str_URL), &bytesWritten, NULL);
             WriteFile(file, url, lstrlenA(url), &bytesWritten, NULL);
             WriteFile(file, str_eol, lstrlenA(str_eol), &bytesWritten, NULL);
+
+            hr = IPropertySetStorage_Open(This->property_set_storage, &FMTID_Intshcut, STGM_READ|STGM_SHARE_EXCLUSIVE, &pPropStgRead);
+            if SUCCEEDED(hr)
+            {
+                hr = IPropertyStorage_ReadMultiple(pPropStgRead, 2, ps, pvread);
+                if SUCCEEDED(hr) 
+                {
+                    char indexString[50];
+                    len = WideCharToMultiByte(CP_UTF8, 0, pvread[0].pwszVal, -1, NULL, 0, 0, 0);
+                    iconfile = heap_alloc(len);
+                    if (iconfile != NULL)
+                    {
+                        WideCharToMultiByte(CP_UTF8, 0, pvread[0].pwszVal, -1, iconfile, len, 0, 0);
+                        WriteFile(file, str_ICONFILE, lstrlenA(str_ICONFILE), &bytesWritten, NULL);
+                        WriteFile(file, iconfile, lstrlenA(iconfile), &bytesWritten, NULL);
+                        WriteFile(file, str_eol, lstrlenA(str_eol), &bytesWritten, NULL);
+                    }
+
+                    sprintf(indexString, "ICONINDEX=%d", pvread[1].iVal);
+                    WriteFile(file, indexString, lstrlenA(indexString), &bytesWritten, NULL);
+                    WriteFile(file, str_eol, lstrlenA(str_eol), &bytesWritten, NULL);
+                }
+                else
+                {
+                    TRACE("Unable to read properties.\n");
+                }
+            }
+            else
+            {
+               TRACE("Unable to get the IPropertyStorage.\n");
+            }
+
             CloseHandle(file);
             if (pszFileName == NULL || fRemember)
                 This->isDirty = FALSE;
-- 
1.6.5


--------------090608050000010209060100--



More information about the wine-patches mailing list