makefiles: Add a standard header for all makefiles to replace the common variable...
[wine] / dlls / shell32 / shlfolder.c
1 /*
2  *      Shell Folder stuff
3  *
4  *      Copyright 1997                  Marcus Meissner
5  *      Copyright 1998, 1999, 2002      Juergen Schmied
6  *
7  *      IShellFolder2 and related interfaces
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23
24 #include "config.h"
25 #include "wine/port.h"
26
27 #include <stdlib.h>
28 #include <string.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31
32 #define COBJMACROS
33 #define NONAMELESSUNION
34 #define NONAMELESSSTRUCT
35
36 #include "winerror.h"
37 #include "windef.h"
38 #include "winbase.h"
39 #include "winreg.h"
40 #include "wingdi.h"
41 #include "winuser.h"
42
43 #include "ole2.h"
44 #include "shlguid.h"
45
46 #include "pidl.h"
47 #include "undocshell.h"
48 #include "shell32_main.h"
49 #include "shlwapi.h"
50 #include "wine/debug.h"
51 #include "shfldr.h"
52
53 WINE_DEFAULT_DEBUG_CHANNEL (shell);
54
55 static const WCHAR wszDotShellClassInfo[] = {
56     '.','S','h','e','l','l','C','l','a','s','s','I','n','f','o',0};
57
58 /***************************************************************************
59  *  SHELL32_GetCustomFolderAttribute (internal function)
60  *
61  * Gets a value from the folder's desktop.ini file, if one exists.
62  *
63  * PARAMETERS
64  *  pidl          [I] Folder containing the desktop.ini file.
65  *  pwszHeading   [I] Heading in .ini file.
66  *  pwszAttribute [I] Attribute in .ini file.
67  *  pwszValue     [O] Buffer to store value into.
68  *  cchValue      [I] Size in characters including NULL of buffer pointed to
69  *                    by pwszValue.
70  *
71  *  RETURNS
72  *    TRUE if returned non-NULL value.
73  *    FALSE otherwise.
74  */
75 static inline BOOL SHELL32_GetCustomFolderAttributeFromPath(
76     LPWSTR pwszFolderPath, LPCWSTR pwszHeading, LPCWSTR pwszAttribute,
77     LPWSTR pwszValue, DWORD cchValue)
78 {
79     static const WCHAR wszDesktopIni[] =
80             {'d','e','s','k','t','o','p','.','i','n','i',0};
81     static const WCHAR wszDefault[] = {0};
82
83     PathAddBackslashW(pwszFolderPath);
84     PathAppendW(pwszFolderPath, wszDesktopIni);
85     return GetPrivateProfileStringW(pwszHeading, pwszAttribute, wszDefault, 
86                                     pwszValue, cchValue, pwszFolderPath);
87 }
88
89 BOOL SHELL32_GetCustomFolderAttribute(
90     LPCITEMIDLIST pidl, LPCWSTR pwszHeading, LPCWSTR pwszAttribute,
91     LPWSTR pwszValue, DWORD cchValue)
92 {
93     DWORD dwAttrib = FILE_ATTRIBUTE_SYSTEM;
94     WCHAR wszFolderPath[MAX_PATH];
95
96     /* Hack around not having system attribute on non-Windows file systems */
97     if (0)
98         dwAttrib = _ILGetFileAttributes(pidl, NULL, 0);
99
100     if (dwAttrib & FILE_ATTRIBUTE_SYSTEM)
101     {
102         if (!SHGetPathFromIDListW(pidl, wszFolderPath))
103             return FALSE;
104
105         return SHELL32_GetCustomFolderAttributeFromPath(wszFolderPath, pwszHeading, 
106                                                 pwszAttribute, pwszValue, cchValue);
107     }
108     return FALSE;
109 }
110
111 /***************************************************************************
112  *  GetNextElement (internal function)
113  *
114  * Gets a part of a string till the first backslash.
115  *
116  * PARAMETERS
117  *  pszNext [IN] string to get the element from
118  *  pszOut  [IN] pointer to buffer which receives string
119  *  dwOut   [IN] length of pszOut
120  *
121  *  RETURNS
122  *    LPSTR pointer to first, not yet parsed char
123  */
124
125 LPCWSTR GetNextElementW (LPCWSTR pszNext, LPWSTR pszOut, DWORD dwOut)
126 {
127     LPCWSTR pszTail = pszNext;
128     DWORD dwCopy;
129
130     TRACE ("(%s %p 0x%08x)\n", debugstr_w(pszNext), pszOut, dwOut);
131
132     *pszOut = 0;
133
134     if (!pszNext || !*pszNext)
135         return NULL;
136
137     while (*pszTail && (*pszTail != (WCHAR) '\\'))
138         pszTail++;
139
140     dwCopy = pszTail - pszNext + 1;
141     lstrcpynW (pszOut, pszNext, (dwOut < dwCopy) ? dwOut : dwCopy);
142
143     if (*pszTail)
144         pszTail++;
145     else
146         pszTail = NULL;
147
148     TRACE ("--(%s %s 0x%08x %p)\n", debugstr_w (pszNext), debugstr_w (pszOut), dwOut, pszTail);
149     return pszTail;
150 }
151
152 HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc,
153                                   LPITEMIDLIST * pidlInOut, LPOLESTR szNext, DWORD * pEaten, DWORD * pdwAttributes)
154 {
155     LPITEMIDLIST pidlOut = NULL, pidlTemp = NULL;
156     IShellFolder *psfChild;
157     HRESULT hr;
158
159     TRACE ("(%p, %p, %p, %s)\n", psf, pbc, pidlInOut ? *pidlInOut : NULL, debugstr_w (szNext));
160
161     /* get the shellfolder for the child pidl and let it analyse further */
162     hr = IShellFolder_BindToObject (psf, *pidlInOut, pbc, &IID_IShellFolder, (LPVOID *) & psfChild);
163
164     if (SUCCEEDED(hr)) {
165         hr = IShellFolder_ParseDisplayName (psfChild, hwndOwner, pbc, szNext, pEaten, &pidlOut, pdwAttributes);
166         IShellFolder_Release (psfChild);
167
168         if (SUCCEEDED(hr)) {
169             pidlTemp = ILCombine (*pidlInOut, pidlOut);
170
171             if (!pidlTemp)
172                 hr = E_OUTOFMEMORY;
173         }
174
175         if (pidlOut)
176             ILFree (pidlOut);
177     }
178
179     ILFree (*pidlInOut);
180     *pidlInOut = pidlTemp;
181
182     TRACE ("-- pidl=%p ret=0x%08x\n", pidlInOut ? *pidlInOut : NULL, hr);
183     return hr;
184 }
185
186 /***********************************************************************
187  *      SHELL32_CoCreateInitSF
188  *
189  * Creates a shell folder and initializes it with a pidl and a root folder
190  * via IPersistFolder3 or IPersistFolder.
191  *
192  * NOTES
193  *   pathRoot can be NULL for Folders being a drive.
194  *   In this case the absolute path is built from pidlChild (eg. C:)
195  */
196 static HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, LPCWSTR pathRoot,
197                 LPCITEMIDLIST pidlChild, REFCLSID clsid, LPVOID * ppvOut)
198 {
199     HRESULT hr;
200
201     TRACE ("(%p %s %p %s %p)\n", pidlRoot, debugstr_w(pathRoot), pidlChild, debugstr_guid(clsid), ppvOut);
202
203     hr = SHCoCreateInstance(NULL, clsid, NULL, &IID_IShellFolder, ppvOut);
204     if (SUCCEEDED (hr))
205     {
206         LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild);
207         IPersistFolder *pPF;
208         IPersistFolder3 *ppf;
209
210         if (_ILIsFolder(pidlChild) &&
211             SUCCEEDED (IUnknown_QueryInterface ((IUnknown *) * ppvOut, &IID_IPersistFolder3, (LPVOID *) & ppf))) 
212         {
213             PERSIST_FOLDER_TARGET_INFO ppfti;
214
215             ZeroMemory (&ppfti, sizeof (ppfti));
216
217             /* fill the PERSIST_FOLDER_TARGET_INFO */
218             ppfti.dwAttributes = -1;
219             ppfti.csidl = -1;
220
221             /* build path */
222             if (pathRoot) {
223                 lstrcpynW (ppfti.szTargetParsingName, pathRoot, MAX_PATH - 1);
224                 PathAddBackslashW(ppfti.szTargetParsingName); /* FIXME: why have drives a backslash here ? */
225             }
226
227             if (pidlChild) {
228                 int len = lstrlenW(ppfti.szTargetParsingName);
229
230                 if (!_ILSimpleGetTextW(pidlChild, ppfti.szTargetParsingName + len, MAX_PATH - len))
231                         hr = E_INVALIDARG;
232             }
233
234             IPersistFolder3_InitializeEx (ppf, NULL, pidlAbsolute, &ppfti);
235             IPersistFolder3_Release (ppf);
236         }
237         else if (SUCCEEDED ((hr = IUnknown_QueryInterface ((IUnknown *) * ppvOut, &IID_IPersistFolder, (LPVOID *) & pPF)))) {
238             IPersistFolder_Initialize (pPF, pidlAbsolute);
239             IPersistFolder_Release (pPF);
240         }
241         ILFree (pidlAbsolute);
242     }
243     TRACE ("-- (%p) ret=0x%08x\n", *ppvOut, hr);
244     return hr;
245 }
246
247 /***********************************************************************
248  *      SHELL32_BindToChild [Internal]
249  *
250  * Common code for IShellFolder_BindToObject.
251  * 
252  * PARAMS
253  *  pidlRoot     [I] The parent shell folder's absolute pidl.
254  *  pathRoot     [I] Absolute dos path of the parent shell folder.
255  *  pidlComplete [I] PIDL of the child. Relative to pidlRoot.
256  *  riid         [I] GUID of the interface, which ppvOut shall be bound to.
257  *  ppvOut       [O] A reference to the child's interface (riid).
258  *
259  * NOTES
260  *  pidlComplete has to contain at least one non empty SHITEMID.
261  *  This function makes special assumptions on the shell namespace, which
262  *  means you probably can't use it for your IShellFolder implementation.
263  */
264 HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
265                              LPCWSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut)
266 {
267     GUID const *clsid;
268     IShellFolder *pSF;
269     HRESULT hr;
270     LPITEMIDLIST pidlChild;
271
272     TRACE("(%p %s %p %s %p)\n", pidlRoot, debugstr_w(pathRoot), pidlComplete, debugstr_guid(riid), ppvOut);
273
274     if (!pidlRoot || !ppvOut || _ILIsEmpty(pidlComplete))
275         return E_INVALIDARG;
276
277     *ppvOut = NULL;
278
279     pidlChild = ILCloneFirst (pidlComplete);
280
281     if ((clsid = _ILGetGUIDPointer (pidlChild))) {
282         /* virtual folder */
283         hr = SHELL32_CoCreateInitSF (pidlRoot, pathRoot, pidlChild, clsid, (LPVOID *)&pSF);
284     } else {
285         /* file system folder */
286         CLSID clsidFolder = CLSID_ShellFSFolder;
287         static const WCHAR wszCLSID[] = {'C','L','S','I','D',0};
288         WCHAR wszCLSIDValue[CHARS_IN_GUID], wszFolderPath[MAX_PATH], *pwszPathTail = wszFolderPath;
289        
290         /* see if folder CLSID should be overridden by desktop.ini file */
291         if (pathRoot) {
292             lstrcpynW(wszFolderPath, pathRoot, MAX_PATH);
293             pwszPathTail = PathAddBackslashW(wszFolderPath);
294         }
295
296         _ILSimpleGetTextW(pidlChild,pwszPathTail,MAX_PATH - (int)(pwszPathTail - wszFolderPath));
297
298         if (SHELL32_GetCustomFolderAttributeFromPath (wszFolderPath,
299             wszDotShellClassInfo, wszCLSID, wszCLSIDValue, CHARS_IN_GUID))
300             CLSIDFromString (wszCLSIDValue, &clsidFolder);
301
302         hr = SHELL32_CoCreateInitSF (pidlRoot, pathRoot, pidlChild,
303                                      &clsidFolder, (LPVOID *)&pSF);
304     }
305     ILFree (pidlChild);
306
307     if (SUCCEEDED (hr)) {
308         if (_ILIsPidlSimple (pidlComplete)) {
309             /* no sub folders */
310             hr = IShellFolder_QueryInterface (pSF, riid, ppvOut);
311         } else {
312             /* go deeper */
313             hr = IShellFolder_BindToObject (pSF, ILGetNext (pidlComplete), NULL, riid, ppvOut);
314         }
315         IShellFolder_Release (pSF);
316     }
317
318     TRACE ("-- returning (%p) 0x%08x\n", *ppvOut, hr);
319
320     return hr;
321 }
322
323 /***********************************************************************
324  *      SHELL32_GetDisplayNameOfChild
325  *
326  * Retrieves the display name of a child object of a shellfolder.
327  *
328  * For a pidl eg. [subpidl1][subpidl2][subpidl3]:
329  * - it binds to the child shellfolder [subpidl1]
330  * - asks it for the displayname of [subpidl2][subpidl3]
331  *
332  * Is possible the pidl is a simple pidl. In this case it asks the
333  * subfolder for the displayname of an empty pidl. The subfolder
334  * returns the own displayname eg. "::{guid}". This is used for
335  * virtual folders with the registry key WantsFORPARSING set.
336  */
337 HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf,
338                                        LPCITEMIDLIST pidl, DWORD dwFlags, LPWSTR szOut, DWORD dwOutLen)
339 {
340     LPITEMIDLIST pidlFirst;
341     HRESULT hr;
342
343     TRACE ("(%p)->(pidl=%p 0x%08x %p 0x%08x)\n", psf, pidl, dwFlags, szOut, dwOutLen);
344     pdump (pidl);
345
346     pidlFirst = ILCloneFirst (pidl);
347     if (pidlFirst) {
348         IShellFolder2 *psfChild;
349
350         hr = IShellFolder_BindToObject (psf, pidlFirst, NULL, &IID_IShellFolder, (LPVOID *) & psfChild);
351         if (SUCCEEDED (hr)) {
352             STRRET strTemp;
353             LPITEMIDLIST pidlNext = ILGetNext (pidl);
354
355             hr = IShellFolder_GetDisplayNameOf (psfChild, pidlNext, dwFlags, &strTemp);
356             if (SUCCEEDED (hr)) {
357                 if(!StrRetToStrNW (szOut, dwOutLen, &strTemp, pidlNext))
358                     hr = E_FAIL;
359             }
360             IShellFolder_Release (psfChild);
361         }
362         ILFree (pidlFirst);
363     } else
364         hr = E_OUTOFMEMORY;
365
366     TRACE ("-- ret=0x%08x %s\n", hr, debugstr_w(szOut));
367
368     return hr;
369 }
370
371 /***********************************************************************
372  *  SHELL32_GetItemAttributes
373  *
374  * NOTES
375  * Observed values:
376  *  folder:     0xE0000177      FILESYSTEM | HASSUBFOLDER | FOLDER
377  *  file:       0x40000177      FILESYSTEM
378  *  drive:      0xf0000144      FILESYSTEM | HASSUBFOLDER | FOLDER | FILESYSANCESTOR
379  *  mycomputer: 0xb0000154      HASSUBFOLDER | FOLDER | FILESYSANCESTOR
380  *  (seems to be default for shell extensions if no registry entry exists)
381  *
382  * win2k:
383  *  folder:    0xF0400177      FILESYSTEM | HASSUBFOLDER | FOLDER | FILESYSANCESTOR | CANMONIKER
384  *  file:      0x40400177      FILESYSTEM | CANMONIKER
385  *  drive      0xF0400154      FILESYSTEM | HASSUBFOLDER | FOLDER | FILESYSANCESTOR | CANMONIKER | CANRENAME (LABEL)
386  *
387  * According to the MSDN documentation this function should not set flags. It claims only to reset flags when necessary.
388  * However it turns out the native shell32.dll _sets_ flags in several cases - so do we.
389  */
390 HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWORD pdwAttributes)
391 {
392     DWORD dwAttributes;
393     BOOL has_guid;
394     static const DWORD dwSupportedAttr=
395                           SFGAO_CANCOPY |           /*0x00000001 */
396                           SFGAO_CANMOVE |           /*0x00000002 */
397                           SFGAO_CANLINK |           /*0x00000004 */
398                           SFGAO_CANRENAME |         /*0x00000010 */
399                           SFGAO_CANDELETE |         /*0x00000020 */
400                           SFGAO_HASPROPSHEET |      /*0x00000040 */
401                           SFGAO_DROPTARGET |        /*0x00000100 */
402                           SFGAO_LINK |              /*0x00010000 */
403                           SFGAO_READONLY |          /*0x00040000 */
404                           SFGAO_HIDDEN |            /*0x00080000 */
405                           SFGAO_FILESYSANCESTOR |   /*0x10000000 */
406                           SFGAO_FOLDER |            /*0x20000000 */
407                           SFGAO_FILESYSTEM |        /*0x40000000 */
408                           SFGAO_HASSUBFOLDER;       /*0x80000000 */
409     
410     TRACE ("0x%08x\n", *pdwAttributes);
411
412     if (*pdwAttributes & ~dwSupportedAttr)
413     {
414         WARN ("attributes 0x%08x not implemented\n", (*pdwAttributes & ~dwSupportedAttr));
415         *pdwAttributes &= dwSupportedAttr;
416     }
417
418     has_guid = _ILGetGUIDPointer(pidl) != NULL;
419
420     dwAttributes = *pdwAttributes;
421
422     if (_ILIsDrive (pidl)) {
423         *pdwAttributes &= SFGAO_HASSUBFOLDER|SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|
424             SFGAO_DROPTARGET|SFGAO_HASPROPSHEET|SFGAO_CANLINK;
425     } else if (has_guid && HCR_GetFolderAttributes(pidl, &dwAttributes)) {
426         *pdwAttributes = dwAttributes;
427     } else if (_ILGetDataPointer (pidl)) {
428         dwAttributes = _ILGetFileAttributes (pidl, NULL, 0);
429
430         if (!dwAttributes && has_guid) {
431             WCHAR path[MAX_PATH];
432             STRRET strret;
433
434             /* File attributes are not present in the internal PIDL structure, so get them from the file system. */
435
436             HRESULT hr = IShellFolder_GetDisplayNameOf(psf, pidl, SHGDN_FORPARSING, &strret);
437
438             if (SUCCEEDED(hr)) {
439                 hr = StrRetToBufW(&strret, pidl, path, MAX_PATH);
440
441                 /* call GetFileAttributes() only for file system paths, not for parsing names like "::{...}" */
442                 if (SUCCEEDED(hr) && path[0]!=':')
443                     dwAttributes = GetFileAttributesW(path);
444             }
445         }
446
447         /* Set common attributes */
448         *pdwAttributes |= SFGAO_FILESYSTEM | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANDELETE | 
449                           SFGAO_CANRENAME | SFGAO_CANLINK | SFGAO_CANMOVE | SFGAO_CANCOPY;
450
451         if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
452             *pdwAttributes |=  (SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR);
453         else
454             *pdwAttributes &= ~(SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR);
455
456         if (dwAttributes & FILE_ATTRIBUTE_HIDDEN)
457             *pdwAttributes |=  SFGAO_HIDDEN;
458         else
459             *pdwAttributes &= ~SFGAO_HIDDEN;
460
461         if (dwAttributes & FILE_ATTRIBUTE_READONLY)
462             *pdwAttributes |=  SFGAO_READONLY;
463         else
464             *pdwAttributes &= ~SFGAO_READONLY;
465
466         if (SFGAO_LINK & *pdwAttributes) {
467             char ext[MAX_PATH];
468
469             if (!_ILGetExtension(pidl, ext, MAX_PATH) || lstrcmpiA(ext, "lnk"))
470                 *pdwAttributes &= ~SFGAO_LINK;
471         }
472     } else {
473         *pdwAttributes &= SFGAO_HASSUBFOLDER|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET|SFGAO_CANRENAME|SFGAO_CANLINK;
474     }
475     TRACE ("-- 0x%08x\n", *pdwAttributes);
476     return S_OK;
477 }
478
479 /***********************************************************************
480  *  SHELL32_CompareIDs
481  */
482 HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
483 {
484     int type1,
485       type2;
486     char szTemp1[MAX_PATH];
487     char szTemp2[MAX_PATH];
488     HRESULT nReturn;
489     LPITEMIDLIST firstpidl,
490       nextpidl1,
491       nextpidl2;
492     IShellFolder *psf;
493
494     /* test for empty pidls */
495     BOOL isEmpty1 = _ILIsDesktop (pidl1);
496     BOOL isEmpty2 = _ILIsDesktop (pidl2);
497
498     if (isEmpty1 && isEmpty2)
499         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 0 );
500     if (isEmpty1)
501         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 );
502     if (isEmpty2)
503         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 );
504
505     /* test for different types. Sort order is the PT_* constant */
506     type1 = _ILGetDataPointer (pidl1)->type;
507     type2 = _ILGetDataPointer (pidl2)->type;
508     if (type1 < type2)
509         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 );
510     else if (type1 > type2)
511         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 );
512
513     /* test for name of pidl */
514     _ILSimpleGetText (pidl1, szTemp1, MAX_PATH);
515     _ILSimpleGetText (pidl2, szTemp2, MAX_PATH);
516     nReturn = lstrcmpiA (szTemp1, szTemp2);
517     if (nReturn < 0)
518         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 );
519     else if (nReturn > 0)
520         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 );
521
522     /* test of complex pidls */
523     firstpidl = ILCloneFirst (pidl1);
524     nextpidl1 = ILGetNext (pidl1);
525     nextpidl2 = ILGetNext (pidl2);
526
527     /* optimizing: test special cases and bind not deeper */
528     /* the deeper shellfolder would do the same */
529     isEmpty1 = _ILIsDesktop (nextpidl1);
530     isEmpty2 = _ILIsDesktop (nextpidl2);
531
532     if (isEmpty1 && isEmpty2) {
533         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 0 );
534     } else if (isEmpty1) {
535         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, (WORD)-1 );
536     } else if (isEmpty2) {
537         return MAKE_HRESULT( SEVERITY_SUCCESS, 0, 1 );
538     /* optimizing end */
539     } else if (SUCCEEDED (IShellFolder_BindToObject (iface, firstpidl, NULL, &IID_IShellFolder, (LPVOID *) & psf))) {
540         nReturn = IShellFolder_CompareIDs (psf, lParam, nextpidl1, nextpidl2);
541         IShellFolder_Release (psf);
542     }
543     ILFree (firstpidl);
544     return nReturn;
545 }
546
547 HRESULT SHELL32_GetColumnDetails(const shvheader *data, int column, SHELLDETAILS *details)
548 {
549     details->fmt = data[column].fmt;
550     details->cxChar = data[column].cxChar;
551
552     if (SHELL_OsIsUnicode())
553     {
554         details->str.u.pOleStr = CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR));
555         if (!details->str.u.pOleStr) return E_OUTOFMEMORY;
556
557         details->str.uType = STRRET_WSTR;
558         LoadStringW(shell32_hInstance, data[column].colnameid, details->str.u.pOleStr, MAX_PATH);
559     }
560     else
561     {
562         details->str.uType = STRRET_CSTR;
563         LoadStringA(shell32_hInstance, data[column].colnameid, details->str.u.cStr, MAX_PATH);
564     }
565
566     return S_OK;
567 }
568
569 /***********************************************************************
570  *  SHCreateLinks
571  *
572  *   Undocumented.
573  */
574 HRESULT WINAPI SHCreateLinks( HWND hWnd, LPCSTR lpszDir, LPDATAOBJECT lpDataObject,
575                               UINT uFlags, LPITEMIDLIST *lppidlLinks)
576 {
577     FIXME("%p %s %p %08x %p\n",hWnd,lpszDir,lpDataObject,uFlags,lppidlLinks);
578     return E_NOTIMPL;
579 }