richedit: Modify ME_GetTextW() to honor CR and LF encodings.
[wine] / dlls / shell32 / shellord.c
1 /*
2  * The parameters of many functions changes between different OS versions
3  * (NT uses Unicode strings, 95 uses ASCII strings)
4  *
5  * Copyright 1997 Marcus Meissner
6  *           1998 Jürgen Schmied
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 #include "config.h"
23
24 #include <string.h>
25 #include <stdarg.h>
26 #include <stdio.h>
27
28 #define COBJMACROS
29
30 #include "winerror.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winreg.h"
34 #include "wine/debug.h"
35 #include "winnls.h"
36
37 #include "shellapi.h"
38 #include "objbase.h"
39 #include "shlguid.h"
40 #include "wingdi.h"
41 #include "winuser.h"
42 #include "shlobj.h"
43 #include "shell32_main.h"
44 #include "undocshell.h"
45 #include "pidl.h"
46 #include "shlwapi.h"
47 #include "commdlg.h"
48
49 WINE_DEFAULT_DEBUG_CHANNEL(shell);
50 WINE_DECLARE_DEBUG_CHANNEL(pidl);
51
52 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
53 /*        !!! it is in both here and comctl32undoc.c      !!! */
54 typedef struct tagCREATEMRULIST
55 {
56     DWORD  cbSize;        /* size of struct */
57     DWORD  nMaxItems;     /* max no. of items in list */
58     DWORD  dwFlags;       /* see below */
59     HKEY   hKey;          /* root reg. key under which list is saved */
60     LPCSTR lpszSubKey;    /* reg. subkey */
61     PROC   lpfnCompare;   /* item compare proc */
62 } CREATEMRULISTA, *LPCREATEMRULISTA;
63
64 /* dwFlags */
65 #define MRUF_STRING_LIST  0 /* list will contain strings */
66 #define MRUF_BINARY_LIST  1 /* list will contain binary data */
67 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
68
69 extern HANDLE WINAPI CreateMRUListA(LPCREATEMRULISTA lpcml);
70 extern DWORD  WINAPI FreeMRUList(HANDLE hMRUList);
71 extern INT    WINAPI AddMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData);
72 extern INT    WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
73 extern INT    WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
74
75
76 /* Get a function pointer from a DLL handle */
77 #define GET_FUNC(func, module, name, fail) \
78   do { \
79     if (!func) { \
80       if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
81       func = (void*)GetProcAddress(SHELL32_h##module, name); \
82       if (!func) return fail; \
83     } \
84   } while (0)
85
86 /* Function pointers for GET_FUNC macro */
87 static HMODULE SHELL32_hshlwapi=NULL;
88 static HANDLE (WINAPI *pSHAllocShared)(LPCVOID,DWORD,DWORD);
89 static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD);
90 static BOOL   (WINAPI *pSHUnlockShared)(LPVOID);
91 static BOOL   (WINAPI *pSHFreeShared)(HANDLE,DWORD);
92
93
94 /*************************************************************************
95  * ParseFieldA                                  [internal]
96  *
97  * copies a field from a ',' delimited string
98  *
99  * first field is nField = 1
100  */
101 DWORD WINAPI ParseFieldA(
102         LPCSTR src,
103         DWORD nField,
104         LPSTR dst,
105         DWORD len)
106 {
107         WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src),nField,dst,len);
108
109         if (!src || !src[0] || !dst || !len)
110           return 0;
111
112         /* skip n fields delimited by ',' */
113         while (nField > 1)
114         {
115           if (*src=='\0') return FALSE;
116           if (*(src++)==',') nField--;
117         }
118
119         /* copy part till the next ',' to dst */
120         while ( *src!='\0' && *src!=',' && (len--)>0 ) *(dst++)=*(src++);
121
122         /* finalize the string */
123         *dst=0x0;
124
125         return TRUE;
126 }
127
128 /*************************************************************************
129  * ParseFieldW                  [internal]
130  *
131  * copies a field from a ',' delimited string
132  *
133  * first field is nField = 1
134  */
135 DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len)
136 {
137         WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src), nField, dst, len);
138
139         if (!src || !src[0] || !dst || !len)
140           return 0;
141
142         /* skip n fields delimited by ',' */
143         while (nField > 1)
144         {
145           if (*src == 0x0) return FALSE;
146           if (*src++ == ',') nField--;
147         }
148
149         /* copy part till the next ',' to dst */
150         while ( *src != 0x0 && *src != ',' && (len--)>0 ) *(dst++) = *(src++);
151
152         /* finalize the string */
153         *dst = 0x0;
154
155         return TRUE;
156 }
157
158 /*************************************************************************
159  * ParseField                   [SHELL32.58]
160  */
161 DWORD WINAPI ParseFieldAW(LPCVOID src, DWORD nField, LPVOID dst, DWORD len)
162 {
163         if (SHELL_OsIsUnicode())
164           return ParseFieldW(src, nField, dst, len);
165         return ParseFieldA(src, nField, dst, len);
166 }
167
168 /*************************************************************************
169  * GetFileNameFromBrowse                        [SHELL32.63]
170  *
171  */
172 BOOL WINAPI GetFileNameFromBrowse(
173         HWND hwndOwner,
174         LPSTR lpstrFile,
175         DWORD nMaxFile,
176         LPCSTR lpstrInitialDir,
177         LPCSTR lpstrDefExt,
178         LPCSTR lpstrFilter,
179         LPCSTR lpstrTitle)
180 {
181     HMODULE hmodule;
182     FARPROC pGetOpenFileNameA;
183     OPENFILENAMEA ofn;
184     BOOL ret;
185
186     TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
187           hwndOwner, lpstrFile, nMaxFile, lpstrInitialDir, lpstrDefExt,
188           lpstrFilter, lpstrTitle);
189
190     hmodule = LoadLibraryA("comdlg32.dll");
191     if(!hmodule) return FALSE;
192     pGetOpenFileNameA = GetProcAddress(hmodule, "GetOpenFileNameA");
193     if(!pGetOpenFileNameA)
194     {
195         FreeLibrary(hmodule);
196         return FALSE;
197     }
198
199     memset(&ofn, 0, sizeof(ofn));
200
201     ofn.lStructSize = sizeof(ofn);
202     ofn.hwndOwner = hwndOwner;
203     ofn.lpstrFilter = lpstrFilter;
204     ofn.lpstrFile = lpstrFile;
205     ofn.nMaxFile = nMaxFile;
206     ofn.lpstrInitialDir = lpstrInitialDir;
207     ofn.lpstrTitle = lpstrTitle;
208     ofn.lpstrDefExt = lpstrDefExt;
209     ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
210     ret = pGetOpenFileNameA(&ofn);
211
212     FreeLibrary(hmodule);
213     return ret;
214 }
215
216 /*************************************************************************
217  * SHGetSetSettings                             [SHELL32.68]
218  */
219 VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
220 {
221   if(bSet)
222   {
223     FIXME("%p 0x%08x TRUE\n", lpss, dwMask);
224   }
225   else
226   {
227     SHGetSettings((LPSHELLFLAGSTATE)lpss,dwMask);
228   }
229 }
230
231 /*************************************************************************
232  * SHGetSettings                                [SHELL32.@]
233  *
234  * NOTES
235  *  the registry path are for win98 (tested)
236  *  and possibly are the same in nt40
237  *
238  */
239 VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask)
240 {
241         HKEY    hKey;
242         DWORD   dwData;
243         DWORD   dwDataSize = sizeof (DWORD);
244
245         TRACE("(%p 0x%08x)\n",lpsfs,dwMask);
246
247         if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
248                                  0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0))
249           return;
250
251         if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize))
252           lpsfs->fShowExtensions  = ((dwData == 0) ?  0 : 1);
253
254         if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize))
255           lpsfs->fShowInfoTip  = ((dwData == 0) ?  0 : 1);
256
257         if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize))
258           lpsfs->fDontPrettyPath  = ((dwData == 0) ?  0 : 1);
259
260         if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize))
261           lpsfs->fHideIcons  = ((dwData == 0) ?  0 : 1);
262
263         if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize))
264           lpsfs->fMapNetDrvBtn  = ((dwData == 0) ?  0 : 1);
265
266         if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize))
267           lpsfs->fShowAttribCol  = ((dwData == 0) ?  0 : 1);
268
269         if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize))
270         { if (dwData == 0)
271           { if (SSF_SHOWALLOBJECTS & dwMask)    lpsfs->fShowAllObjects  = 0;
272             if (SSF_SHOWSYSFILES & dwMask)      lpsfs->fShowSysFiles  = 0;
273           }
274           else if (dwData == 1)
275           { if (SSF_SHOWALLOBJECTS & dwMask)    lpsfs->fShowAllObjects  = 1;
276             if (SSF_SHOWSYSFILES & dwMask)      lpsfs->fShowSysFiles  = 0;
277           }
278           else if (dwData == 2)
279           { if (SSF_SHOWALLOBJECTS & dwMask)    lpsfs->fShowAllObjects  = 0;
280             if (SSF_SHOWSYSFILES & dwMask)      lpsfs->fShowSysFiles  = 1;
281           }
282         }
283         RegCloseKey (hKey);
284
285         TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
286 }
287
288 /*************************************************************************
289  * SHShellFolderView_Message                    [SHELL32.73]
290  *
291  * Send a message to an explorer cabinet window.
292  *
293  * PARAMS
294  *  hwndCabinet [I] The window containing the shellview to communicate with
295  *  dwMessage   [I] The SFVM message to send
296  *  dwParam     [I] Message parameter
297  *
298  * RETURNS
299  *  fixme.
300  *
301  * NOTES
302  *  Message SFVM_REARRANGE = 1
303  *
304  *    This message gets sent when a column gets clicked to instruct the
305  *    shell view to re-sort the item list. dwParam identifies the column
306  *    that was clicked.
307  */
308 LRESULT WINAPI SHShellFolderView_Message(
309         HWND hwndCabinet,
310         UINT uMessage,
311         LPARAM lParam)
312 {
313         FIXME("%p %08x %08lx stub\n",hwndCabinet, uMessage, lParam);
314         return 0;
315 }
316
317 /*************************************************************************
318  * RegisterShellHook                            [SHELL32.181]
319  *
320  * Register a shell hook.
321  *
322  * PARAMS
323  *      hwnd   [I]  Window handle
324  *      dwType [I]  Type of hook.
325  *
326  * NOTES
327  *     Exported by ordinal
328  */
329 BOOL WINAPI RegisterShellHook(
330         HWND hWnd,
331         DWORD dwType)
332 {
333         FIXME("(%p,0x%08x):stub.\n",hWnd, dwType);
334         return TRUE;
335 }
336
337 /*************************************************************************
338  * ShellMessageBoxW                             [SHELL32.182]
339  *
340  * See ShellMessageBoxA.
341  *
342  * NOTE:
343  * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
344  * because we can't forward to it in the .spec file since it's exported by
345  * ordinal. If you change the implementation here please update the code in
346  * shlwapi as well.
347  */
348 int WINAPIV ShellMessageBoxW(
349         HINSTANCE hInstance,
350         HWND hWnd,
351         LPCWSTR lpText,
352         LPCWSTR lpCaption,
353         UINT uType,
354         ...)
355 {
356         WCHAR   szText[100],szTitle[100];
357         LPCWSTR pszText = szText, pszTitle = szTitle;
358         LPWSTR  pszTemp;
359         va_list args;
360         int     ret;
361
362         va_start(args, uType);
363         /* wvsprintfA(buf,fmt, args); */
364
365         TRACE("(%p,%p,%p,%p,%08x)\n",
366             hInstance,hWnd,lpText,lpCaption,uType);
367
368         if (IS_INTRESOURCE(lpCaption))
369           LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
370         else
371           pszTitle = lpCaption;
372
373         if (IS_INTRESOURCE(lpText))
374           LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
375         else
376           pszText = lpText;
377
378         FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
379                        pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
380
381         va_end(args);
382
383         ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
384         LocalFree((HLOCAL)pszTemp);
385         return ret;
386 }
387
388 /*************************************************************************
389  * ShellMessageBoxA                             [SHELL32.183]
390  *
391  * Format and output an error message.
392  *
393  * PARAMS
394  *  hInstance [I] Instance handle of message creator
395  *  hWnd      [I] Window handle of message creator
396  *  lpText    [I] Resource Id of title or LPSTR
397  *  lpCaption [I] Resource Id of title or LPSTR
398  *  uType     [I] Type of error message
399  *
400  * RETURNS
401  *  A return value from MessageBoxA().
402  *
403  * NOTES
404  *     Exported by ordinal
405  */
406 int WINAPIV ShellMessageBoxA(
407         HINSTANCE hInstance,
408         HWND hWnd,
409         LPCSTR lpText,
410         LPCSTR lpCaption,
411         UINT uType,
412         ...)
413 {
414         char    szText[100],szTitle[100];
415         LPCSTR  pszText = szText, pszTitle = szTitle;
416         LPSTR   pszTemp;
417         va_list args;
418         int     ret;
419
420         va_start(args, uType);
421         /* wvsprintfA(buf,fmt, args); */
422
423         TRACE("(%p,%p,%p,%p,%08x)\n",
424             hInstance,hWnd,lpText,lpCaption,uType);
425
426         if (IS_INTRESOURCE(lpCaption))
427           LoadStringA(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle));
428         else
429           pszTitle = lpCaption;
430
431         if (IS_INTRESOURCE(lpText))
432           LoadStringA(hInstance, LOWORD(lpText), szText, sizeof(szText));
433         else
434           pszText = lpText;
435
436         FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
437                        pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
438
439         va_end(args);
440
441         ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
442         LocalFree((HLOCAL)pszTemp);
443         return ret;
444 }
445
446 /*************************************************************************
447  * SHRegisterDragDrop                           [SHELL32.86]
448  *
449  * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
450  * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
451  * for details. Under Windows 98 this function initializes the true OLE when called
452  * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
453  *
454  * We follow Windows 98 behaviour.
455  *
456  * NOTES
457  *     exported by ordinal
458  *
459  * SEE ALSO
460  *     RegisterDragDrop, SHLoadOLE
461  */
462 HRESULT WINAPI SHRegisterDragDrop(
463         HWND hWnd,
464         LPDROPTARGET pDropTarget)
465 {
466         static BOOL ole_initialized = FALSE;
467         HRESULT hr;
468
469         TRACE("(%p,%p)\n", hWnd, pDropTarget);
470
471         if (!ole_initialized)
472         {
473             hr = OleInitialize(NULL);
474             if (FAILED(hr))
475                 return hr;
476             ole_initialized = TRUE;
477         }
478         return RegisterDragDrop(hWnd, pDropTarget);
479 }
480
481 /*************************************************************************
482  * SHRevokeDragDrop                             [SHELL32.87]
483  *
484  * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
485  * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
486  * for details. Function removed from Windows Vista.
487  *
488  * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
489  * not called.
490  *
491  * NOTES
492  *     exported by ordinal
493  *
494  * SEE ALSO
495  *     RevokeDragDrop, SHLoadOLE
496  */
497 HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
498 {
499     TRACE("(%p)\n", hWnd);
500     return RevokeDragDrop(hWnd);
501 }
502
503 /*************************************************************************
504  * SHDoDragDrop                                 [SHELL32.88]
505  *
506  * Probably equivalent to DoDragDrop but under Windows 9x it could use the
507  * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
508  * for details
509  *
510  * NOTES
511  *     exported by ordinal
512  *
513  * SEE ALSO
514  *     DoDragDrop, SHLoadOLE
515  */
516 HRESULT WINAPI SHDoDragDrop(
517         HWND hWnd,
518         LPDATAOBJECT lpDataObject,
519         LPDROPSOURCE lpDropSource,
520         DWORD dwOKEffect,
521         LPDWORD pdwEffect)
522 {
523     FIXME("(%p %p %p 0x%08x %p):stub.\n",
524     hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
525         return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
526 }
527
528 /*************************************************************************
529  * ArrangeWindows                               [SHELL32.184]
530  *
531  */
532 WORD WINAPI ArrangeWindows(
533         HWND hwndParent,
534         DWORD dwReserved,
535         LPCRECT lpRect,
536         WORD cKids,
537         CONST HWND * lpKids)
538 {
539     FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
540            hwndParent, dwReserved, lpRect, cKids, lpKids);
541     return 0;
542 }
543
544 /*************************************************************************
545  * SignalFileOpen                               [SHELL32.103]
546  *
547  * NOTES
548  *     exported by ordinal
549  */
550 DWORD WINAPI
551 SignalFileOpen (DWORD dwParam1)
552 {
553     FIXME("(0x%08x):stub.\n", dwParam1);
554
555     return 0;
556 }
557
558 /*************************************************************************
559  * SHADD_get_policy - helper function for SHAddToRecentDocs
560  *
561  * PARAMETERS
562  *   policy    [IN]  policy name (null termed string) to find
563  *   type      [OUT] ptr to DWORD to receive type
564  *   buffer    [OUT] ptr to area to hold data retrieved
565  *   len       [IN/OUT] ptr to DWORD holding size of buffer and getting
566  *                      length filled
567  *
568  * RETURNS
569  *   result of the SHQueryValueEx call
570  */
571 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
572 {
573     HKEY Policy_basekey;
574     INT ret;
575
576     /* Get the key for the policies location in the registry
577      */
578     if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
579                       "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
580                       0, KEY_READ, &Policy_basekey)) {
581
582         if (RegOpenKeyExA(HKEY_CURRENT_USER,
583                           "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
584                           0, KEY_READ, &Policy_basekey)) {
585             TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
586                   policy);
587             *len = 0;
588             return ERROR_FILE_NOT_FOUND;
589         }
590     }
591
592     /* Retrieve the data if it exists
593      */
594     ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len);
595     RegCloseKey(Policy_basekey);
596     return ret;
597 }
598
599
600 /*************************************************************************
601  * SHADD_compare_mru - helper function for SHAddToRecentDocs
602  *
603  * PARAMETERS
604  *   data1     [IN] data being looked for
605  *   data2     [IN] data in MRU
606  *   cbdata    [IN] length from FindMRUData call (not used)
607  *
608  * RETURNS
609  *   position within MRU list that data was added.
610  */
611 static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData)
612 {
613     return lstrcmpiA(data1, data2);
614 }
615
616 /*************************************************************************
617  * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
618  *
619  * PARAMETERS
620  *   mruhandle    [IN] handle for created MRU list
621  *   doc_name     [IN] null termed pure doc name
622  *   new_lnk_name [IN] null termed path and file name for .lnk file
623  *   buffer       [IN/OUT] 2048 byte area to construct MRU data
624  *   len          [OUT] ptr to int to receive space used in buffer
625  *
626  * RETURNS
627  *   position within MRU list that data was added.
628  */
629 static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPCSTR doc_name, LPCSTR new_lnk_name,
630                                      LPSTR buffer, INT *len)
631 {
632     LPSTR ptr;
633     INT wlen;
634
635     /*FIXME: Document:
636      *  RecentDocs MRU data structure seems to be:
637      *    +0h   document file name w/ terminating 0h
638      *    +nh   short int w/ size of remaining
639      *    +n+2h 02h 30h, or 01h 30h, or 00h 30h  -  unknown
640      *    +n+4h 10 bytes zeros  -   unknown
641      *    +n+eh shortcut file name w/ terminating 0h
642      *    +n+e+nh 3 zero bytes  -  unknown
643      */
644
645     /* Create the MRU data structure for "RecentDocs"
646          */
647     ptr = buffer;
648     lstrcpyA(ptr, doc_name);
649     ptr += (lstrlenA(buffer) + 1);
650     wlen= lstrlenA(new_lnk_name) + 1 + 12;
651     *((short int*)ptr) = wlen;
652     ptr += 2;   /* step past the length */
653     *(ptr++) = 0x30;  /* unknown reason */
654     *(ptr++) = 0;     /* unknown, but can be 0x00, 0x01, 0x02 */
655     memset(ptr, 0, 10);
656     ptr += 10;
657     lstrcpyA(ptr, new_lnk_name);
658     ptr += (lstrlenA(new_lnk_name) + 1);
659     memset(ptr, 0, 3);
660     ptr += 3;
661     *len = ptr - buffer;
662
663     /* Add the new entry into the MRU list
664      */
665     return AddMRUData(mruhandle, (LPCVOID)buffer, *len);
666 }
667
668 /*************************************************************************
669  * SHAddToRecentDocs                            [SHELL32.@]
670  *
671  * Modify (add/clear) Shell's list of recently used documents.
672  *
673  * PARAMETERS
674  *   uFlags  [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
675  *   pv      [IN] string or pidl, NULL clears the list
676  *
677  * NOTES
678  *     exported by name
679  *
680  * FIXME
681  *  convert to unicode
682  */
683 void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
684 {
685 /* If list is a string list lpfnCompare has the following prototype
686  * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
687  * for binary lists the prototype is
688  * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
689  * where cbData is the no. of bytes to compare.
690  * Need to check what return value means identical - 0?
691  */
692
693
694     UINT olderrormode;
695     HKEY HCUbasekey;
696     CHAR doc_name[MAX_PATH];
697     CHAR link_dir[MAX_PATH];
698     CHAR new_lnk_filepath[MAX_PATH];
699     CHAR new_lnk_name[MAX_PATH];
700     IMalloc *ppM;
701     LPITEMIDLIST pidl;
702     HWND hwnd = 0;       /* FIXME:  get real window handle */
703     INT ret;
704     DWORD data[64], datalen, type;
705
706     TRACE("%04x %p\n", uFlags, pv);
707
708     /*FIXME: Document:
709      *  RecentDocs MRU data structure seems to be:
710      *    +0h   document file name w/ terminating 0h
711      *    +nh   short int w/ size of remaining
712      *    +n+2h 02h 30h, or 01h 30h, or 00h 30h  -  unknown
713      *    +n+4h 10 bytes zeros  -   unknown
714      *    +n+eh shortcut file name w/ terminating 0h
715      *    +n+e+nh 3 zero bytes  -  unknown
716      */
717
718     /* See if we need to do anything.
719      */
720     datalen = 64;
721     ret=SHADD_get_policy( "NoRecentDocsHistory", &type, &data, &datalen);
722     if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) {
723         ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret);
724         return;
725     }
726     if (ret == ERROR_SUCCESS) {
727         if (!( (type == REG_DWORD) ||
728                ((type == REG_BINARY) && (datalen == 4)) )) {
729             ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
730                 type, datalen);
731             return;
732         }
733
734         TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
735         /* now test the actual policy value */
736         if ( data[0] != 0)
737             return;
738     }
739
740     /* Open key to where the necessary info is
741      */
742     /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
743      *        and the close should be done during the _DETACH. The resulting
744      *        key is stored in the DLL global data.
745      */
746     if (RegCreateKeyExA(HKEY_CURRENT_USER,
747                         "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
748                         0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
749         ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
750         return;
751     }
752
753     /* Get path to user's "Recent" directory
754      */
755     if(SUCCEEDED(SHGetMalloc(&ppM))) {
756         if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
757                                                  &pidl))) {
758             SHGetPathFromIDListA(pidl, link_dir);
759             IMalloc_Free(ppM, pidl);
760         }
761         else {
762             /* serious issues */
763             link_dir[0] = 0;
764             ERR("serious issues 1\n");
765         }
766         IMalloc_Release(ppM);
767     }
768     else {
769         /* serious issues */
770         link_dir[0] = 0;
771         ERR("serious issues 2\n");
772     }
773     TRACE("Users Recent dir %s\n", link_dir);
774
775     /* If no input, then go clear the lists */
776     if (!pv) {
777         /* clear user's Recent dir
778          */
779
780         /* FIXME: delete all files in "link_dir"
781          *
782          * while( more files ) {
783          *    lstrcpyA(old_lnk_name, link_dir);
784          *    PathAppendA(old_lnk_name, filenam);
785          *    DeleteFileA(old_lnk_name);
786          * }
787          */
788         FIXME("should delete all files in %s\\\n", link_dir);
789
790         /* clear MRU list
791          */
792         /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
793          *  HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
794          *  and naturally it fails w/ rc=2. It should do it against
795          *  HKEY_CURRENT_USER which is where it is stored, and where
796          *  the MRU routines expect it!!!!
797          */
798         RegDeleteKeyA(HCUbasekey, "RecentDocs");
799         RegCloseKey(HCUbasekey);
800         return;
801     }
802
803     /* Have data to add, the jobs to be done:
804      *   1. Add document to MRU list in registry "HKCU\Software\
805      *      Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
806      *   2. Add shortcut to document in the user's Recent directory
807      *      (CSIDL_RECENT).
808      *   3. Add shortcut to Start menu's Documents submenu.
809      */
810
811     /* Get the pure document name from the input
812      */
813     switch (uFlags)
814     {
815     case SHARD_PIDL:
816         SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name);
817         break;
818
819     case SHARD_PATHA:
820         lstrcpynA(doc_name, (LPCSTR)pv, MAX_PATH);
821         break;
822
823     case SHARD_PATHW:
824         WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pv, -1, doc_name, MAX_PATH, NULL, NULL);
825         break;
826
827     default:
828         FIXME("Unsupported flags: %u\n", uFlags);
829         return;
830     }
831
832     TRACE("full document name %s\n", debugstr_a(doc_name));
833     PathStripPathA(doc_name);
834     TRACE("stripped document name %s\n", debugstr_a(doc_name));
835
836
837     /* ***  JOB 1: Update registry for ...\Explorer\RecentDocs list  *** */
838
839     {  /* on input needs:
840         *      doc_name    -  pure file-spec, no path
841         *      link_dir    -  path to the user's Recent directory
842         *      HCUbasekey  -  key of ...Windows\CurrentVersion\Explorer" node
843         * creates:
844         *      new_lnk_name-  pure file-spec, no path for new .lnk file
845         *      new_lnk_filepath
846         *                  -  path and file name of new .lnk file
847         */
848         CREATEMRULISTA mymru;
849         HANDLE mruhandle;
850         INT len, pos, bufused, err;
851         INT i;
852         DWORD attr;
853         CHAR buffer[2048];
854         CHAR *ptr;
855         CHAR old_lnk_name[MAX_PATH];
856         short int slen;
857
858         mymru.cbSize = sizeof(CREATEMRULISTA);
859         mymru.nMaxItems = 15;
860         mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE;
861         mymru.hKey = HCUbasekey;
862         mymru.lpszSubKey = "RecentDocs";
863         mymru.lpfnCompare = (PROC)SHADD_compare_mru;
864         mruhandle = CreateMRUListA(&mymru);
865         if (!mruhandle) {
866             /* MRU failed */
867             ERR("MRU processing failed, handle zero\n");
868             RegCloseKey(HCUbasekey);
869             return;
870         }
871         len = lstrlenA(doc_name);
872         pos = FindMRUData(mruhandle, doc_name, len, 0);
873
874         /* Now get the MRU entry that will be replaced
875          * and delete the .lnk file for it
876          */
877         if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos,
878                                     buffer, 2048)) != -1) {
879             ptr = buffer;
880             ptr += (lstrlenA(buffer) + 1);
881             slen = *((short int*)ptr);
882             ptr += 2;  /* skip the length area */
883             if (bufused >= slen + (ptr-buffer)) {
884                 /* buffer size looks good */
885                 ptr += 12; /* get to string */
886                 len = bufused - (ptr-buffer);  /* get length of buf remaining */
887                 if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
888                     /* appears to be good string */
889                     lstrcpyA(old_lnk_name, link_dir);
890                     PathAppendA(old_lnk_name, ptr);
891                     if (!DeleteFileA(old_lnk_name)) {
892                         if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
893                             if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
894                                 ERR("Delete for %s failed, err=%d, attr=%08x\n",
895                                     old_lnk_name, err, attr);
896                             }
897                             else {
898                                 TRACE("old .lnk file %s did not exist\n",
899                                       old_lnk_name);
900                             }
901                         }
902                         else {
903                             ERR("Delete for %s failed, attr=%08x\n",
904                                 old_lnk_name, attr);
905                         }
906                     }
907                     else {
908                         TRACE("deleted old .lnk file %s\n", old_lnk_name);
909                     }
910                 }
911             }
912         }
913
914         /* Create usable .lnk file name for the "Recent" directory
915          */
916         wsprintfA(new_lnk_name, "%s.lnk", doc_name);
917         lstrcpyA(new_lnk_filepath, link_dir);
918         PathAppendA(new_lnk_filepath, new_lnk_name);
919         i = 1;
920         olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
921         while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
922             i++;
923             wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
924             lstrcpyA(new_lnk_filepath, link_dir);
925             PathAppendA(new_lnk_filepath, new_lnk_name);
926         }
927         SetErrorMode(olderrormode);
928         TRACE("new shortcut will be %s\n", new_lnk_filepath);
929
930         /* Now add the new MRU entry and data
931          */
932         pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name,
933                                         buffer, &len);
934         FreeMRUList(mruhandle);
935         TRACE("Updated MRU list, new doc is position %d\n", pos);
936     }
937
938     /* ***  JOB 2: Create shortcut in user's "Recent" directory  *** */
939
940     {  /* on input needs:
941         *      doc_name    -  pure file-spec, no path
942         *      new_lnk_filepath
943         *                  -  path and file name of new .lnk file
944         *      uFlags[in]  -  flags on call to SHAddToRecentDocs
945         *      pv[in]      -  document path/pidl on call to SHAddToRecentDocs
946         */
947         IShellLinkA *psl = NULL;
948         IPersistFile *pPf = NULL;
949         HRESULT hres;
950         CHAR desc[MAX_PATH];
951         WCHAR widelink[MAX_PATH];
952
953         CoInitialize(0);
954
955         hres = CoCreateInstance( &CLSID_ShellLink,
956                                  NULL,
957                                  CLSCTX_INPROC_SERVER,
958                                  &IID_IShellLinkA,
959                                  (LPVOID )&psl);
960         if(SUCCEEDED(hres)) {
961
962             hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
963                                              (LPVOID *)&pPf);
964             if(FAILED(hres)) {
965                 /* bombed */
966                 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
967                 goto fail;
968             }
969
970             /* Set the document path or pidl */
971             if (uFlags == SHARD_PIDL) {
972                 hres = IShellLinkA_SetIDList(psl, (LPCITEMIDLIST) pv);
973             } else {
974                 hres = IShellLinkA_SetPath(psl, (LPCSTR) pv);
975             }
976             if(FAILED(hres)) {
977                 /* bombed */
978                 ERR("failed Set{IDList|Path} %08x\n", hres);
979                 goto fail;
980             }
981
982             lstrcpyA(desc, "Shortcut to ");
983             lstrcatA(desc, doc_name);
984             hres = IShellLinkA_SetDescription(psl, desc);
985             if(FAILED(hres)) {
986                 /* bombed */
987                 ERR("failed SetDescription %08x\n", hres);
988                 goto fail;
989             }
990
991             MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
992                                 widelink, MAX_PATH);
993             /* create the short cut */
994             hres = IPersistFile_Save(pPf, widelink, TRUE);
995             if(FAILED(hres)) {
996                 /* bombed */
997                 ERR("failed IPersistFile::Save %08x\n", hres);
998                 IPersistFile_Release(pPf);
999                 IShellLinkA_Release(psl);
1000                 goto fail;
1001             }
1002             hres = IPersistFile_SaveCompleted(pPf, widelink);
1003             IPersistFile_Release(pPf);
1004             IShellLinkA_Release(psl);
1005             TRACE("shortcut %s has been created, result=%08x\n",
1006                   new_lnk_filepath, hres);
1007         }
1008         else {
1009             ERR("CoCreateInstance failed, hres=%08x\n", hres);
1010         }
1011     }
1012
1013  fail:
1014     CoUninitialize();
1015
1016     /* all done */
1017     RegCloseKey(HCUbasekey);
1018     return;
1019 }
1020
1021 /*************************************************************************
1022  * SHCreateShellFolderViewEx                    [SHELL32.174]
1023  *
1024  * Create a new instance of the default Shell folder view object.
1025  *
1026  * RETURNS
1027  *  Success: S_OK
1028  *  Failure: error value
1029  *
1030  * NOTES
1031  *  see IShellFolder::CreateViewObject
1032  */
1033 HRESULT WINAPI SHCreateShellFolderViewEx(
1034         LPCSFV psvcbi,    /* [in] shelltemplate struct */
1035         IShellView **ppv) /* [out] IShellView pointer */
1036 {
1037         IShellView * psf;
1038         HRESULT hRes;
1039
1040         TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1041           psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
1042           psvcbi->fvm, psvcbi->psvOuter);
1043
1044         psf = IShellView_Constructor(psvcbi->pshf);
1045
1046         if (!psf)
1047           return E_OUTOFMEMORY;
1048
1049         IShellView_AddRef(psf);
1050         hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1051         IShellView_Release(psf);
1052
1053         return hRes;
1054 }
1055 /*************************************************************************
1056  *  SHWinHelp                                   [SHELL32.127]
1057  *
1058  */
1059 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
1060 {       FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v,w,x,z);
1061         return 0;
1062 }
1063 /*************************************************************************
1064  *  SHRunControlPanel [SHELL32.161]
1065  *
1066  */
1067 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
1068 {       FIXME("0x%08x 0x%08x stub\n",x,z);
1069         return 0;
1070 }
1071
1072 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1073 /*************************************************************************
1074  * SHSetInstanceExplorer                        [SHELL32.176]
1075  *
1076  * NOTES
1077  *  Sets the interface
1078  */
1079 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1080 {       TRACE("%p\n", lpUnknown);
1081         SHELL32_IExplorerInterface = lpUnknown;
1082 }
1083 /*************************************************************************
1084  * SHGetInstanceExplorer                        [SHELL32.@]
1085  *
1086  * NOTES
1087  *  gets the interface pointer of the explorer and a reference
1088  */
1089 HRESULT WINAPI SHGetInstanceExplorer (IUnknown **lpUnknown)
1090 {       TRACE("%p\n", lpUnknown);
1091
1092         *lpUnknown = SHELL32_IExplorerInterface;
1093
1094         if (!SHELL32_IExplorerInterface)
1095           return E_FAIL;
1096
1097         IUnknown_AddRef(SHELL32_IExplorerInterface);
1098         return NOERROR;
1099 }
1100 /*************************************************************************
1101  * SHFreeUnusedLibraries                        [SHELL32.123]
1102  *
1103  * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1104  * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1105  * for details
1106  *
1107  * NOTES
1108  *     exported by ordinal
1109  *
1110  * SEE ALSO
1111  *     CoFreeUnusedLibraries, SHLoadOLE
1112  */
1113 void WINAPI SHFreeUnusedLibraries (void)
1114 {
1115         FIXME("stub\n");
1116         CoFreeUnusedLibraries();
1117 }
1118 /*************************************************************************
1119  * DAD_AutoScroll                               [SHELL32.129]
1120  *
1121  */
1122 BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, LPPOINT pt)
1123 {
1124     FIXME("hwnd = %p %p %p\n",hwnd,samples,pt);
1125     return 0;
1126 }
1127 /*************************************************************************
1128  * DAD_DragEnter                                [SHELL32.130]
1129  *
1130  */
1131 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1132 {
1133     FIXME("hwnd = %p\n",hwnd);
1134     return FALSE;
1135 }
1136 /*************************************************************************
1137  * DAD_DragEnterEx                              [SHELL32.131]
1138  *
1139  */
1140 BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p)
1141 {
1142     FIXME("hwnd = %p (%d,%d)\n",hwnd,p.x,p.y);
1143     return FALSE;
1144 }
1145 /*************************************************************************
1146  * DAD_DragMove                         [SHELL32.134]
1147  *
1148  */
1149 BOOL WINAPI DAD_DragMove(POINT p)
1150 {
1151     FIXME("(%d,%d)\n",p.x,p.y);
1152     return FALSE;
1153 }
1154 /*************************************************************************
1155  * DAD_DragLeave                                [SHELL32.132]
1156  *
1157  */
1158 BOOL WINAPI DAD_DragLeave(VOID)
1159 {
1160     FIXME("\n");
1161     return FALSE;
1162 }
1163 /*************************************************************************
1164  * DAD_SetDragImage                             [SHELL32.136]
1165  *
1166  * NOTES
1167  *  exported by name
1168  */
1169 BOOL WINAPI DAD_SetDragImage(
1170         HIMAGELIST himlTrack,
1171         LPPOINT lppt)
1172 {
1173         FIXME("%p %p stub\n",himlTrack, lppt);
1174   return 0;
1175 }
1176 /*************************************************************************
1177  * DAD_ShowDragImage                            [SHELL32.137]
1178  *
1179  * NOTES
1180  *  exported by name
1181  */
1182 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1183 {
1184         FIXME("0x%08x stub\n",bShow);
1185         return 0;
1186 }
1187
1188 static const WCHAR szwCabLocation[] = {
1189   'S','o','f','t','w','a','r','e','\\',
1190   'M','i','c','r','o','s','o','f','t','\\',
1191   'W','i','n','d','o','w','s','\\',
1192   'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1193   'E','x','p','l','o','r','e','r','\\',
1194   'C','a','b','i','n','e','t','S','t','a','t','e',0
1195 };
1196
1197 static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 };
1198
1199 /*************************************************************************
1200  * ReadCabinetState                             [SHELL32.651] NT 4.0
1201  *
1202  */
1203 BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
1204 {
1205         HKEY hkey = 0;
1206         DWORD type, r;
1207
1208         TRACE("%p %d\n", cs, length);
1209
1210         if( (cs == NULL) || (length < (int)sizeof(*cs))  )
1211                 return FALSE;
1212
1213         r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1214         if( r == ERROR_SUCCESS )
1215         {
1216                 type = REG_BINARY;
1217                 r = RegQueryValueExW( hkey, szwSettings, 
1218                         NULL, &type, (LPBYTE)cs, (LPDWORD)&length );
1219                 RegCloseKey( hkey );
1220                         
1221         }
1222
1223         /* if we can't read from the registry, create default values */
1224         if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) ||
1225                 (cs->cLength != length) )
1226         {
1227                 ERR("Initializing shell cabinet settings\n");
1228                 memset(cs, 0, sizeof(*cs));
1229                 cs->cLength          = sizeof(*cs);
1230                 cs->nVersion         = 2;
1231                 cs->fFullPathTitle   = FALSE;
1232                 cs->fSaveLocalView   = TRUE;
1233                 cs->fNotShell        = FALSE;
1234                 cs->fSimpleDefault   = TRUE;
1235                 cs->fDontShowDescBar = FALSE;
1236                 cs->fNewWindowMode   = FALSE;
1237                 cs->fShowCompColor   = FALSE;
1238                 cs->fDontPrettyNames = FALSE;
1239                 cs->fAdminsCreateCommonGroups = TRUE;
1240                 cs->fMenuEnumFilter  = 96;
1241         }
1242         
1243         return TRUE;
1244 }
1245
1246 /*************************************************************************
1247  * WriteCabinetState                            [SHELL32.652] NT 4.0
1248  *
1249  */
1250 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1251 {
1252         DWORD r;
1253         HKEY hkey = 0;
1254
1255         TRACE("%p\n",cs);
1256
1257         if( cs == NULL )
1258                 return FALSE;
1259
1260         r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0,
1261                  NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
1262         if( r == ERROR_SUCCESS )
1263         {
1264                 r = RegSetValueExW( hkey, szwSettings, 0, 
1265                         REG_BINARY, (LPBYTE) cs, cs->cLength);
1266
1267                 RegCloseKey( hkey );
1268         }
1269
1270         return (r==ERROR_SUCCESS);
1271 }
1272
1273 /*************************************************************************
1274  * FileIconInit                                 [SHELL32.660]
1275  *
1276  */
1277 BOOL WINAPI FileIconInit(BOOL bFullInit)
1278 {       FIXME("(%s)\n", bFullInit ? "true" : "false");
1279         return 0;
1280 }
1281 /*************************************************************************
1282  * IsUserAdmin                                  [SHELL32.680] NT 4.0
1283  *
1284  */
1285 HRESULT WINAPI IsUserAdmin(void)
1286 {       FIXME("stub\n");
1287         return TRUE;
1288 }
1289
1290 /*************************************************************************
1291  * SHAllocShared                                [SHELL32.520]
1292  *
1293  * See shlwapi.SHAllocShared
1294  */
1295 HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
1296 {
1297     GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
1298     return pSHAllocShared(lpvData, dwSize, dwProcId);
1299 }
1300
1301 /*************************************************************************
1302  * SHLockShared                                 [SHELL32.521]
1303  *
1304  * See shlwapi.SHLockShared
1305  */
1306 LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
1307 {
1308     GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
1309     return pSHLockShared(hShared, dwProcId);
1310 }
1311
1312 /*************************************************************************
1313  * SHUnlockShared                               [SHELL32.522]
1314  *
1315  * See shlwapi.SHUnlockShared
1316  */
1317 BOOL WINAPI SHUnlockShared(LPVOID lpView)
1318 {
1319     GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
1320     return pSHUnlockShared(lpView);
1321 }
1322
1323 /*************************************************************************
1324  * SHFreeShared                                 [SHELL32.523]
1325  *
1326  * See shlwapi.SHFreeShared
1327  */
1328 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
1329 {
1330     GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
1331     return pSHFreeShared(hShared, dwProcId);
1332 }
1333
1334 /*************************************************************************
1335  * SetAppStartingCursor                         [SHELL32.99]
1336  */
1337 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1338 {       FIXME("hwnd=%p 0x%04x stub\n",u,v );
1339         return 0;
1340 }
1341
1342 /*************************************************************************
1343  * SHLoadOLE                                    [SHELL32.151]
1344  *
1345  * To reduce the memory usage of Windows 95, its shell32 contained an
1346  * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1347  * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1348  * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1349  * would just call the Co* functions.
1350  *
1351  * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1352  * information from the shell32 "mini-COM" to ole32.dll.
1353  *
1354  * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1355  * detailed description.
1356  *
1357  * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1358  * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1359  * hack in SHCoCreateInstance)
1360  */
1361 HRESULT WINAPI SHLoadOLE(LPARAM lParam)
1362 {       FIXME("0x%08lx stub\n",lParam);
1363         return S_OK;
1364 }
1365 /*************************************************************************
1366  * DriveType                                    [SHELL32.64]
1367  *
1368  */
1369 HRESULT WINAPI DriveType(DWORD u)
1370 {       FIXME("0x%04x stub\n",u);
1371         return 0;
1372 }
1373 /*************************************************************************
1374  * InvalidateDriveType                  [SHELL32.65]
1375  *
1376  */
1377 int WINAPI InvalidateDriveType(int u)
1378 {       FIXME("0x%08x stub\n",u);
1379         return 0;
1380 }
1381 /*************************************************************************
1382  * SHAbortInvokeCommand                         [SHELL32.198]
1383  *
1384  */
1385 HRESULT WINAPI SHAbortInvokeCommand(void)
1386 {       FIXME("stub\n");
1387         return 1;
1388 }
1389 /*************************************************************************
1390  * SHOutOfMemoryMessageBox                      [SHELL32.126]
1391  *
1392  */
1393 int WINAPI SHOutOfMemoryMessageBox(
1394         HWND hwndOwner,
1395         LPCSTR lpCaption,
1396         UINT uType)
1397 {
1398         FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1399         return 0;
1400 }
1401 /*************************************************************************
1402  * SHFlushClipboard                             [SHELL32.121]
1403  *
1404  */
1405 HRESULT WINAPI SHFlushClipboard(void)
1406 {       FIXME("stub\n");
1407         return 1;
1408 }
1409
1410 /*************************************************************************
1411  * SHWaitForFileToOpen                          [SHELL32.97]
1412  *
1413  */
1414 BOOL WINAPI SHWaitForFileToOpen(
1415         LPCITEMIDLIST pidl,
1416         DWORD dwFlags,
1417         DWORD dwTimeout)
1418 {
1419         FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1420         return 0;
1421 }
1422
1423 /************************************************************************
1424  *      @                               [SHELL32.654]
1425  *
1426  * NOTES
1427  *  first parameter seems to be a pointer (same as passed to WriteCabinetState)
1428  *  second one could be a size (0x0c). The size is the same as the structure saved to
1429  *  HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1430  *  I'm (js) guessing: this one is just ReadCabinetState ;-)
1431  */
1432 HRESULT WINAPI shell32_654 (CABINETSTATE *cs, int length)
1433 {
1434         TRACE("%p %d\n",cs,length);
1435         return ReadCabinetState(cs,length);
1436 }
1437
1438 /************************************************************************
1439  *      RLBuildListOfPaths                      [SHELL32.146]
1440  *
1441  * NOTES
1442  *   builds a DPA
1443  */
1444 DWORD WINAPI RLBuildListOfPaths (void)
1445 {       FIXME("stub\n");
1446         return 0;
1447 }
1448 /************************************************************************
1449  *      SHValidateUNC                           [SHELL32.173]
1450  *
1451  */
1452 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1453 {
1454         FIXME("0x%08x 0x%08x 0x%08x stub\n",x,y,z);
1455         return 0;
1456 }
1457
1458 /************************************************************************
1459  *      DoEnvironmentSubstA                     [SHELL32.@]
1460  *
1461  * Replace %KEYWORD% in the str with the value of variable KEYWORD
1462  * from environment. If it is not found the %KEYWORD% is left
1463  * intact. If the buffer is too small, str is not modified.
1464  *
1465  * PARAMS
1466  *  pszString  [I] '\0' terminated string with %keyword%.
1467  *             [O] '\0' terminated string with %keyword% substituted.
1468  *  cchString  [I] size of str.
1469  *
1470  * RETURNS
1471  *     cchString length in the HIWORD;
1472  *     TRUE in LOWORD if subst was successful and FALSE in other case
1473  */
1474 DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
1475 {
1476     LPSTR dst;
1477     BOOL res = FALSE;
1478     FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
1479     if (pszString == NULL) /* Really return 0? */
1480         return 0;
1481     if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
1482     {
1483         DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
1484         if (num && num < cchString) /* dest buffer is too small */
1485         {
1486             res = TRUE;
1487             memcpy(pszString, dst, num);
1488         }
1489         HeapFree(GetProcessHeap(), 0, dst);
1490     }
1491     return MAKELONG(res,cchString); /* Always cchString? */
1492 }
1493
1494 /************************************************************************
1495  *      DoEnvironmentSubstW                     [SHELL32.@]
1496  *
1497  * See DoEnvironmentSubstA.  
1498  */
1499 DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
1500 {
1501         FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
1502         return MAKELONG(FALSE,cchString);
1503 }
1504
1505 /************************************************************************
1506  *      DoEnvironmentSubst                      [SHELL32.53]
1507  *
1508  * See DoEnvironmentSubstA.  
1509  */
1510 DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y)
1511 {
1512     if (SHELL_OsIsUnicode())
1513         return DoEnvironmentSubstW(x, y);
1514     return DoEnvironmentSubstA(x, y);
1515 }
1516
1517 /*************************************************************************
1518  *      @                             [SHELL32.243]
1519  *
1520  * Win98+ by-ordinal routine.  In Win98 this routine returns zero and
1521  * does nothing else.  Possibly this does something in NT or SHELL32 5.0?
1522  *
1523  */
1524
1525 BOOL WINAPI shell32_243(DWORD a, DWORD b)
1526 {
1527   return FALSE;
1528 }
1529
1530 /*************************************************************************
1531  *      @       [SHELL32.714]
1532  */
1533 DWORD WINAPI SHELL32_714(LPVOID x)
1534 {
1535         FIXME("(%s)stub\n", debugstr_w(x));
1536         return 0;
1537 }
1538
1539 typedef struct _PSXA
1540 {
1541     UINT uiCount;
1542     UINT uiAllocated;
1543     IShellPropSheetExt *pspsx[1];
1544 } PSXA, *PPSXA;
1545
1546 typedef struct _PSXA_CALL
1547 {
1548     LPFNADDPROPSHEETPAGE lpfnAddReplaceWith;
1549     LPARAM lParam;
1550     BOOL bCalled;
1551     BOOL bMultiple;
1552     UINT uiCount;
1553 } PSXA_CALL, *PPSXA_CALL;
1554
1555 static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam)
1556 {
1557     PPSXA_CALL Call = (PPSXA_CALL)lParam;
1558
1559     if (Call != NULL)
1560     {
1561         if ((Call->bMultiple || !Call->bCalled) &&
1562             Call->lpfnAddReplaceWith(hpage, Call->lParam))
1563         {
1564             Call->bCalled = TRUE;
1565             Call->uiCount++;
1566             return TRUE;
1567         }
1568     }
1569
1570     return FALSE;
1571 }
1572
1573 /*************************************************************************
1574  *      SHAddFromPropSheetExtArray      [SHELL32.167]
1575  */
1576 UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
1577 {
1578     PSXA_CALL Call;
1579     UINT i;
1580     PPSXA psxa = (PPSXA)hpsxa;
1581
1582     TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam);
1583
1584     if (psxa)
1585     {
1586         ZeroMemory(&Call, sizeof(Call));
1587         Call.lpfnAddReplaceWith = lpfnAddPage;
1588         Call.lParam = lParam;
1589         Call.bMultiple = TRUE;
1590
1591         /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1592         for (i = 0; i != psxa->uiCount; i++)
1593         {
1594             psxa->pspsx[i]->lpVtbl->AddPages(psxa->pspsx[i], PsxaCall, (LPARAM)&Call);
1595         }
1596
1597         return Call.uiCount;
1598     }
1599
1600     return 0;
1601 }
1602
1603 /*************************************************************************
1604  *      SHCreatePropSheetExtArray       [SHELL32.168]
1605  */
1606 HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
1607 {
1608     return SHCreatePropSheetExtArrayEx(hKey, pszSubKey, max_iface, NULL);
1609 }
1610
1611 /*************************************************************************
1612  *      SHCreatePropSheetExtArrayEx     [SHELL32.194]
1613  */
1614 HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, LPDATAOBJECT pDataObj)
1615 {
1616     static const WCHAR szPropSheetSubKey[] = {'s','h','e','l','l','e','x','\\','P','r','o','p','e','r','t','y','S','h','e','e','t','H','a','n','d','l','e','r','s',0};
1617     WCHAR szHandler[64];
1618     DWORD dwHandlerLen;
1619     WCHAR szClsidHandler[39];
1620     DWORD dwClsidSize;
1621     CLSID clsid;
1622     LONG lRet;
1623     DWORD dwIndex;
1624     IShellExtInit *psxi;
1625     IShellPropSheetExt *pspsx;
1626     HKEY hkBase, hkPropSheetHandlers;
1627     PPSXA psxa = NULL;
1628
1629     TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface);
1630
1631     if (max_iface == 0)
1632         return NULL;
1633
1634     /* Open the registry key */
1635     lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase);
1636     if (lRet != ERROR_SUCCESS)
1637         return NULL;
1638
1639     lRet = RegOpenKeyExW(hkBase, szPropSheetSubKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkPropSheetHandlers);
1640     RegCloseKey(hkBase);
1641     if (lRet == ERROR_SUCCESS)
1642     {
1643         /* Create and initialize the Property Sheet Extensions Array */
1644         psxa = (PPSXA)LocalAlloc(LMEM_FIXED, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1645         if (psxa)
1646         {
1647             ZeroMemory(psxa, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1648             psxa->uiAllocated = max_iface;
1649
1650             /* Enumerate all subkeys and attempt to load the shell extensions */
1651             dwIndex = 0;
1652             do
1653             {
1654                 dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]);
1655                 lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL);
1656                 if (lRet != ERROR_SUCCESS)
1657                 {
1658                     if (lRet == ERROR_MORE_DATA)
1659                         continue;
1660
1661                     if (lRet == ERROR_NO_MORE_ITEMS)
1662                         lRet = ERROR_SUCCESS;
1663                     break;
1664                 }
1665
1666                 dwClsidSize = sizeof(szClsidHandler);
1667                 if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
1668                 {
1669                     /* Force a NULL-termination and convert the string */
1670                     szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
1671                     if (SUCCEEDED(SHCLSIDFromStringW(szClsidHandler, &clsid)))
1672                     {
1673                         /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1674                            Only if both interfaces are supported it's a real shell extension.
1675                            Then call IShellExtInit's Initialize method. */
1676                         if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx)))
1677                         {
1678                             if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi)))
1679                             {
1680                                 if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey)))
1681                                 {
1682                                     /* Add the IShellPropSheetExt instance to the array */
1683                                     psxa->pspsx[psxa->uiCount++] = pspsx;
1684                                 }
1685                                 else
1686                                 {
1687                                     psxi->lpVtbl->Release(psxi);
1688                                     pspsx->lpVtbl->Release(pspsx);
1689                                 }
1690                             }
1691                             else
1692                                 pspsx->lpVtbl->Release(pspsx);
1693                         }
1694                     }
1695                 }
1696
1697             } while (psxa->uiCount != psxa->uiAllocated);
1698         }
1699         else
1700             lRet = ERROR_NOT_ENOUGH_MEMORY;
1701
1702         RegCloseKey(hkPropSheetHandlers);
1703     }
1704
1705     if (lRet != ERROR_SUCCESS && psxa)
1706     {
1707         SHDestroyPropSheetExtArray((HPSXA)psxa);
1708         psxa = NULL;
1709     }
1710
1711     return (HPSXA)psxa;
1712 }
1713
1714 /*************************************************************************
1715  *      SHReplaceFromPropSheetExtArray  [SHELL32.170]
1716  */
1717 UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
1718 {
1719     PSXA_CALL Call;
1720     UINT i;
1721     PPSXA psxa = (PPSXA)hpsxa;
1722
1723     TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam);
1724
1725     if (psxa)
1726     {
1727         ZeroMemory(&Call, sizeof(Call));
1728         Call.lpfnAddReplaceWith = lpfnReplaceWith;
1729         Call.lParam = lParam;
1730
1731         /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1732            Each shell extension is only allowed to call the callback once during the callback. */
1733         for (i = 0; i != psxa->uiCount; i++)
1734         {
1735             Call.bCalled = FALSE;
1736             psxa->pspsx[i]->lpVtbl->ReplacePage(psxa->pspsx[i], uPageID, PsxaCall, (LPARAM)&Call);
1737         }
1738
1739         return Call.uiCount;
1740     }
1741
1742     return 0;
1743 }
1744
1745 /*************************************************************************
1746  *      SHDestroyPropSheetExtArray      [SHELL32.169]
1747  */
1748 void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
1749 {
1750     UINT i;
1751     PPSXA psxa = (PPSXA)hpsxa;
1752
1753     TRACE("(%p)\n", hpsxa);
1754
1755     if (psxa)
1756     {
1757         for (i = 0; i != psxa->uiCount; i++)
1758         {
1759             psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]);
1760         }
1761
1762         LocalFree((HLOCAL)psxa);
1763     }
1764 }
1765
1766 /*************************************************************************
1767  *      CIDLData_CreateFromIDArray      [SHELL32.83]
1768  *
1769  *  Create IDataObject from PIDLs??
1770  */
1771 HRESULT WINAPI CIDLData_CreateFromIDArray(
1772         LPCITEMIDLIST pidlFolder,
1773         DWORD cpidlFiles,
1774         LPCITEMIDLIST *lppidlFiles,
1775         LPDATAOBJECT *ppdataObject)
1776 {
1777     UINT i;
1778     HWND hwnd = 0;   /*FIXME: who should be hwnd of owner? set to desktop */
1779
1780     TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1781     if (TRACE_ON(pidl))
1782     {
1783         pdump (pidlFolder);
1784         for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1785     }
1786     *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1787                                              lppidlFiles, cpidlFiles);
1788     if (*ppdataObject) return S_OK;
1789     return E_OUTOFMEMORY;
1790 }
1791
1792 /*************************************************************************
1793  * SHCreateStdEnumFmtEtc                        [SHELL32.74]
1794  *
1795  * NOTES
1796  *
1797  */
1798 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1799         DWORD cFormats,
1800         const FORMATETC *lpFormats,
1801         LPENUMFORMATETC *ppenumFormatetc)
1802 {
1803         IEnumFORMATETC *pef;
1804         HRESULT hRes;
1805         TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1806
1807         pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1808         if (!pef)
1809           return E_OUTOFMEMORY;
1810
1811         IEnumFORMATETC_AddRef(pef);
1812         hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1813         IEnumFORMATETC_Release(pef);
1814
1815         return hRes;
1816 }
1817
1818
1819 /*************************************************************************
1820  *              SHELL32_256 (SHELL32.256)
1821  */
1822 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1823 {
1824     HRESULT ret = S_OK;
1825
1826     FIXME("stub %p 0x%08x %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1827
1828     if (!lpdw0 || *lpdw0 != 0x10)
1829         ret = E_INVALIDARG;
1830     else
1831     {
1832         LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1833
1834         if (!lpdata)
1835             ret = E_OUTOFMEMORY;
1836         else
1837         {
1838             /* Initialize and return unknown lpdata structure */
1839         }
1840     }
1841
1842     return ret;
1843 }
1844
1845 /*************************************************************************
1846  *              SHFindFiles (SHELL32.90)
1847  */
1848 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1849 {
1850     FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1851     return FALSE;
1852 }
1853
1854 /*************************************************************************
1855  *              SHUpdateImageW (SHELL32.192)
1856  *
1857  * Notifies the shell that an icon in the system image list has been changed.
1858  *
1859  * PARAMS
1860  *  pszHashItem [I] Path to file that contains the icon.
1861  *  iIndex      [I] Zero-based index of the icon in the file.
1862  *  uFlags      [I] Flags determining the icon attributes. See notes.
1863  *  iImageIndex [I] Index of the icon in the system image list.
1864  *
1865  * RETURNS
1866  *  Nothing
1867  *
1868  * NOTES
1869  *  uFlags can be one or more of the following flags:
1870  *  GIL_NOTFILENAME - pszHashItem is not a file name.
1871  *  GIL_SIMULATEDOC - Create a document icon using the specified icon.
1872  */
1873 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
1874 {
1875     FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
1876 }
1877
1878 /*************************************************************************
1879  *              SHUpdateImageA (SHELL32.191)
1880  *
1881  * See SHUpdateImageW.
1882  */
1883 VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex)
1884 {
1885     FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex);
1886 }
1887
1888 INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra)
1889 {
1890     FIXME("%p - stub\n", pidlExtra);
1891
1892     return -1;
1893 }
1894
1895 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
1896 {
1897     FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
1898
1899     return TRUE;
1900 }
1901
1902 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
1903                               UINT uFlags)
1904 {
1905     FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo), debugstr_a(pszDir),
1906           pszName, pfMustCopy, uFlags);
1907
1908     return FALSE;
1909 }
1910
1911 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
1912                               UINT uFlags)
1913 {
1914     FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
1915           pszName, pfMustCopy, uFlags);
1916
1917     return FALSE;
1918 }
1919
1920 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
1921 {
1922     FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
1923
1924     return S_OK;
1925 }
1926
1927 HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
1928 {
1929     FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1930
1931     return S_OK;
1932 }
1933
1934 HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
1935 {
1936     FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1937
1938     return S_OK;
1939 }
1940
1941 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
1942 {
1943     FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
1944
1945     return SHFMT_NOFORMAT;
1946 }
1947
1948 HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1949 {
1950     FIXME("%s, %p - stub\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1951
1952     pSHQueryRBInfo->i64Size = 0;
1953     pSHQueryRBInfo->i64NumItems = 0;
1954
1955     return S_OK;
1956 }
1957
1958 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1959 {
1960     FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1961
1962     pSHQueryRBInfo->i64Size = 0;
1963     pSHQueryRBInfo->i64NumItems = 0;
1964
1965     return S_OK;
1966 }
1967
1968 /*************************************************************************
1969  *              SHSetLocalizedName (SHELL32.@)
1970  */
1971 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
1972 {
1973     FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
1974
1975     return S_OK;
1976 }
1977
1978 /*************************************************************************
1979  *              LinkWindow_RegisterClass (SHELL32.258)
1980  */
1981 BOOL WINAPI LinkWindow_RegisterClass(void)
1982 {
1983     FIXME("()\n");
1984     return TRUE;
1985 }
1986
1987 /*************************************************************************
1988  *              LinkWindow_UnregisterClass (SHELL32.259)
1989  */
1990 BOOL WINAPI LinkWindow_UnregisterClass(void)
1991 {
1992     FIXME("()\n");
1993     return TRUE;
1994 }