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