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