Build most dlls as separate shared libraries.
[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 #include <string.h>
9 #include "winerror.h"
10 #include "winreg.h"
11 #include "debugtools.h"
12 #include "winnls.h"
13 #include "winversion.h"
14 #include "heap.h"
15
16 #include "shellapi.h"
17 #include "shlobj.h"
18 #include "shell32_main.h"
19 #include "wine/undocshell.h"
20 #include "shpolicy.h"
21
22 DEFAULT_DEBUG_CHANNEL(shell)
23
24 /*************************************************************************
25  * SHChangeNotifyRegister                       [SHELL32.2]
26  *
27  * NOTES
28  *   Idlist is an array of structures and Count specifies how many items in the array
29  *   (usually just one I think).
30  */
31 DWORD WINAPI
32 SHChangeNotifyRegister(
33     HWND hwnd,
34     LONG events1,
35     LONG events2,
36     DWORD msg,
37     int count,
38     IDSTRUCT *idlist)
39 {       FIXME("(0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p):stub.\n",
40                 hwnd,events1,events2,msg,count,idlist);
41         return 0;
42 }
43 /*************************************************************************
44  * SHChangeNotifyDeregister                     [SHELL32.4]
45  */
46 DWORD WINAPI
47 SHChangeNotifyDeregister(LONG x1)
48 {       FIXME("(0x%08lx):stub.\n",x1);
49         return 0;
50 }
51 /*************************************************************************
52  * NTSHChangeNotifyRegister                     [SHELL32.640]
53  * NOTES
54  *   Idlist is an array of structures and Count specifies how many items in the array
55  *   (usually just one I think).
56  */
57 DWORD WINAPI NTSHChangeNotifyRegister(
58     HWND hwnd,
59     LONG events1,
60     LONG events2,
61     DWORD msg,
62     int count,
63     IDSTRUCT *idlist)
64 {       FIXME("(0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p):stub.\n",
65                 hwnd,events1,events2,msg,count,idlist);
66         return 0;
67 }
68 /*************************************************************************
69  * NTSHChangeNotifyDeregister                   [SHELL32.641]
70  */
71 DWORD WINAPI NTSHChangeNotifyDeregister(LONG x1)
72 {       FIXME("(0x%08lx):stub.\n",x1);
73         return 0;
74 }
75
76 /*************************************************************************
77  * ParseField                                   [SHELL32.58]
78  *
79  */
80 DWORD WINAPI ParseFieldA(LPCSTR src, DWORD field, LPSTR dst, DWORD len) 
81 {       WARN("('%s',0x%08lx,%p,%ld) semi-stub.\n",src,field,dst,len);
82
83         if (!src || !src[0] || !dst || !len)
84           return 0;
85
86         if (field >1)
87         { field--;      
88           while (field)
89           { if (*src==0x0) return FALSE;
90             if (*src==',') field--;
91             src++;
92           }
93         }
94
95         while (*src!=0x00 && *src!=',' && len>0) 
96         { *dst=*src; dst++, src++; len--;
97         }
98         *dst=0x0;
99         
100         return TRUE;
101 }
102
103 /*************************************************************************
104  * PickIconDlg                                  [SHELL32.62]
105  * 
106  */
107 DWORD WINAPI PickIconDlg(DWORD x,DWORD y,DWORD z,DWORD a) 
108 {       FIXME("(%08lx,%08lx,%08lx,%08lx):stub.\n",x,y,z,a);
109         return 0xffffffff;
110 }
111
112 /*************************************************************************
113  * GetFileNameFromBrowse                        [SHELL32.63]
114  * 
115  */
116 DWORD WINAPI GetFileNameFromBrowse(HWND howner, LPSTR targetbuf, DWORD len, DWORD x, LPCSTR suffix, LPCSTR y, LPCSTR cmd) 
117 {       FIXME("(%04x,%p,%ld,%08lx,%s,%s,%s):stub.\n",
118             howner,targetbuf,len,x,suffix,y,cmd);
119     /* puts up a Open Dialog and requests input into targetbuf */
120     /* OFN_HIDEREADONLY|OFN_NOCHANGEDIR|OFN_FILEMUSTEXIST|OFN_unknown */
121     lstrcpyA(targetbuf,"x:\\dummy.exe");
122     return 1;
123 }
124
125 /*************************************************************************
126  * SHGetSettings                                [SHELL32.68]
127  * 
128  * NOTES
129  *  the registry path are for win98 (tested)
130  *  and possibly are the same in nt40
131  */
132 void WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask, DWORD dwx)
133 {
134         HKEY    hKey;
135         DWORD   dwData;
136         DWORD   dwDataSize = sizeof (DWORD);
137
138         TRACE("(%p 0x%08lx 0x%08lx)\n",lpsfs,dwMask, dwx);
139         
140         if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
141                                  0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0))
142           return;
143         
144         if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize))
145           lpsfs->fShowExtensions  = ((dwData == 0) ?  0 : 1);
146
147         if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize))
148           lpsfs->fShowInfoTip  = ((dwData == 0) ?  0 : 1);
149
150         if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize))
151           lpsfs->fDontPrettyPath  = ((dwData == 0) ?  0 : 1);
152
153         if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize))
154           lpsfs->fHideIcons  = ((dwData == 0) ?  0 : 1);
155
156         if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize))
157           lpsfs->fMapNetDrvBtn  = ((dwData == 0) ?  0 : 1);
158
159         if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize))
160           lpsfs->fShowAttribCol  = ((dwData == 0) ?  0 : 1);
161
162         if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize))
163         { if (dwData == 0)
164           { if (SSF_SHOWALLOBJECTS & dwMask)    lpsfs->fShowAllObjects  = 0;
165             if (SSF_SHOWSYSFILES & dwMask)      lpsfs->fShowSysFiles  = 0;
166           }
167           else if (dwData == 1)
168           { if (SSF_SHOWALLOBJECTS & dwMask)    lpsfs->fShowAllObjects  = 1;
169             if (SSF_SHOWSYSFILES & dwMask)      lpsfs->fShowSysFiles  = 0;
170           }
171           else if (dwData == 2)
172           { if (SSF_SHOWALLOBJECTS & dwMask)    lpsfs->fShowAllObjects  = 0;
173             if (SSF_SHOWSYSFILES & dwMask)      lpsfs->fShowSysFiles  = 1;
174           }
175         }
176         RegCloseKey (hKey);
177
178         TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
179 }
180
181 /*************************************************************************
182  * SHShellFolderView_Message                    [SHELL32.73]
183  *
184  * PARAMETERS
185  *  hwndCabinet defines the explorer cabinet window that contains the 
186  *              shellview you need to communicate with
187  *  uMsg        identifying the SFVM enum to perform
188  *  lParam
189  *
190  * NOTES
191  *  Message SFVM_REARRANGE = 1
192  *    This message gets sent when a column gets clicked to instruct the
193  *    shell view to re-sort the item list. lParam identifies the column
194  *    that was clicked.
195  */
196 int WINAPI SHShellFolderView_Message(HWND hwndCabinet,UINT uMsg,LPARAM lParam)
197 { FIXME("%04x %08ux %08lx stub\n",hwndCabinet,uMsg,lParam);
198   return 0;
199 }
200
201 /*************************************************************************
202  * OleStrToStrN                                 [SHELL32.78]
203  */
204 BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle) 
205 {
206         TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
207         return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
208 }
209
210 BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle) 
211 {
212         TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
213
214         if (lstrcpynW ( lpwStr, lpOle, nwStr))
215         { return lstrlenW (lpwStr);
216         }
217         return 0;
218 }
219
220 BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn) 
221 {
222         if (VERSION_OsIsUnicode())
223           return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
224         return OleStrToStrNA (lpOut, nOut, lpIn, nIn);
225 }
226
227 /*************************************************************************
228  * StrToOleStrN                                 [SHELL32.79]
229  *  lpMulti, nMulti, nWide [IN]
230  *  lpWide [OUT]
231  */
232 BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr) 
233 {
234         TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
235         return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
236 }
237 BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr) 
238 {
239         TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
240
241         if (lstrcpynW (lpWide, lpStrW, nWide))
242         { return lstrlenW (lpWide);
243         }
244         return 0;
245 }
246
247 BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr) 
248 {
249         if (VERSION_OsIsUnicode())
250           return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
251         return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
252 }
253
254 /*************************************************************************
255  * RegisterShellHook                            [SHELL32.181]
256  *
257  * PARAMS
258  *      hwnd [I]  window handle
259  *      y    [I]  flag ????
260  * 
261  * NOTES
262  *     exported by ordinal
263  */
264 void WINAPI RegisterShellHook(HWND hwnd, DWORD y) {
265     FIXME("(0x%08x,0x%08lx):stub.\n",hwnd,y);
266 }
267 /*************************************************************************
268  * ShellMessageBoxW                             [SHELL32.182]
269  *
270  * Format and output errormessage.
271  *
272  * idText       resource ID of title or LPSTR
273  * idTitle      resource ID of title or LPSTR
274  *
275  * NOTES
276  *     exported by ordinal
277  */
278 INT __cdecl
279 ShellMessageBoxW(HMODULE hmod,HWND hwnd,DWORD idText,DWORD idTitle,DWORD uType,LPCVOID arglist) 
280 {       WCHAR   szText[100],szTitle[100],szTemp[256];
281         LPWSTR   pszText = &szText[0], pszTitle = &szTitle[0];
282         LPVOID  args = &arglist;
283
284         TRACE("(%08lx,%08lx,%08lx,%08lx,%08lx,%p)\n",(DWORD)hmod,(DWORD)hwnd,idText,idTitle,uType,arglist);
285
286         if (!HIWORD (idTitle))
287           LoadStringW(hmod,idTitle,pszTitle,100);
288         else
289           pszTitle = (LPWSTR)idTitle;
290
291         if (! HIWORD (idText))
292           LoadStringW(hmod,idText,pszText,100);
293         else
294           pszText = (LPWSTR)idText;
295
296         FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY ,szText,0,0,szTemp,256,args);
297         return MessageBoxW(hwnd,szTemp,szTitle,uType);
298 }
299
300 /*************************************************************************
301  * ShellMessageBoxA                             [SHELL32.183]
302  */
303 INT __cdecl
304 ShellMessageBoxA(HMODULE hmod,HWND hwnd,DWORD idText,DWORD idTitle,DWORD uType,LPCVOID arglist) 
305 {       char    szText[100],szTitle[100],szTemp[256];
306         LPSTR   pszText = &szText[0], pszTitle = &szTitle[0];
307         LPVOID  args = &arglist;
308
309         TRACE("(%08lx,%08lx,%08lx,%08lx,%08lx,%p)\n", (DWORD)hmod,(DWORD)hwnd,idText,idTitle,uType,arglist);
310
311         if (!HIWORD (idTitle))
312           LoadStringA(hmod,idTitle,pszTitle,100);
313         else
314           pszTitle = (LPSTR)idTitle;
315
316         if (! HIWORD (idText))
317           LoadStringA(hmod,idText,pszText,100);
318         else
319           pszText = (LPSTR)idText;
320
321         FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY ,pszText,0,0,szTemp,256,args);
322         return MessageBoxA(hwnd,szTemp,pszTitle,uType);
323 }
324
325 /*************************************************************************
326  * SHRestricted                         [SHELL32.100]
327  *
328  * walks through policy table, queries <app> key, <type> value, returns 
329  * queried (DWORD) value, and caches it between called to SHInitRestricted
330  * to prevent unnecessary registry access.
331  *
332  * NOTES
333  *     exported by ordinal
334  *
335  * REFERENCES: 
336  *     MS System Policy Editor
337  *     98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
338  *     "The Windows 95 Registry", by John Woram, 1996 MIS: Press
339  */
340 DWORD WINAPI SHRestricted (DWORD pol) {
341         char regstr[256];
342         HKEY    xhkey;
343         DWORD   retval, polidx, i, datsize = 4;
344
345         TRACE("(%08lx)\n",pol);
346
347         polidx = -1;
348
349         /* scan to see if we know this policy ID */
350         for (i = 0; i < SHELL_MAX_POLICIES; i++)
351         {
352              if (pol == sh32_policy_table[i].polflags)
353              {
354                  polidx = i;
355                  break;
356              }
357         }
358
359         if (polidx == -1)
360         {
361             /* we don't know this policy, return 0 */
362             TRACE("unknown policy: (%08lx)\n", pol);
363                 return 0;
364         }
365
366         /* we have a known policy */
367         lstrcpyA(regstr, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
368         lstrcatA(regstr, sh32_policy_table[polidx].appstr);
369
370         /* first check if this policy has been cached, return it if so */
371         if (sh32_policy_table[polidx].cache != SHELL_NO_POLICY)
372         {
373             return sh32_policy_table[polidx].cache;
374         }
375
376         /* return 0 and don't set the cache if any registry errors occur */
377         retval = 0;
378         if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
379         {
380             if (RegQueryValueExA(xhkey, sh32_policy_table[polidx].keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
381             {
382                 sh32_policy_table[polidx].cache = retval;
383             }
384
385         RegCloseKey(xhkey);
386 }
387
388         return retval;
389 }
390
391 /*************************************************************************
392  *      SHInitRestricted                         [SHELL32.244]
393  *
394  * Win98+ by-ordinal only routine called by Explorer and MSIE 4 and 5.
395  * Inits the policy cache used by SHRestricted to avoid excess
396  * registry access.
397  *
398  * INPUTS
399  * Two inputs: one is a string or NULL.  If non-NULL the pointer
400  * should point to a string containing the following exact text:
401  * "Software\Microsoft\Windows\CurrentVersion\Policies".
402  * The other input is unused.
403  *
404  * NOTES
405  * If the input is non-NULL and does not point to a string containing
406  * that exact text the routine will do nothing.
407  *
408  * If the text does match or the pointer is NULL, then the routine
409  * will init SHRestricted()'s policy cache to all 0xffffffff and
410  * returns 0xffffffff as well.
411  *
412  * I haven't yet run into anything calling this with inputs other than
413  * (NULL, NULL), so I may have the inputs reversed.
414  */
415
416 BOOL WINAPI SHInitRestricted(LPSTR inpRegKey, LPSTR parm2)
417 {
418      int i;
419
420      TRACE("(%p, %p)\n", inpRegKey, parm2);
421
422      /* first check - if input is non-NULL and points to the secret
423         key string, then pass.  Otherwise return 0.
424      */
425
426      if (inpRegKey != (LPSTR)NULL)
427      {
428          if (lstrcmpiA(inpRegKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"))
429          {
430              /* doesn't match, fail */
431              return 0;
432          }
433      }                               
434
435      /* check passed, init all policy cache entries with SHELL_NO_POLICY */
436      for (i = 0; i < SHELL_MAX_POLICIES; i++)
437      {
438           sh32_policy_table[i].cache = SHELL_NO_POLICY;
439      }
440
441      return SHELL_NO_POLICY;
442 }
443
444 /*************************************************************************
445  * SHCreateDirectory                            [SHELL32.165]
446  *
447  * NOTES
448  *  exported by ordinal
449  *  not sure about LPSECURITY_ATTRIBUTES
450  */
451 DWORD WINAPI SHCreateDirectory(LPSECURITY_ATTRIBUTES sec,LPCSTR path) {
452         TRACE("(%p,%s):stub.\n",sec,path);
453         if (CreateDirectoryA(path,sec))
454                 return TRUE;
455         /* SHChangeNotify(8,1,path,0); */
456         return FALSE;
457 #if 0
458         if (SHELL32_79(path,(LPVOID)x))
459                 return 0;
460         FIXME("(%08lx,%s):stub.\n",x,path);
461         return 0;
462 #endif
463 }
464
465 /*************************************************************************
466  * SHFree                                       [SHELL32.195]
467  *
468  * NOTES
469  *     free_ptr() - frees memory using IMalloc
470  *     exported by ordinal
471  */
472 #define MEM_DEBUG 0
473 DWORD WINAPI SHFree(LPVOID x) 
474 {
475 #if MEM_DEBUG
476         WORD len = *(LPWORD)(x-2);
477
478         if ( *(LPWORD)(x+len) != 0x7384)
479           ERR("MAGIC2!\n");
480
481         if ( (*(LPWORD)(x-4)) != 0x8271)
482           ERR("MAGIC1!\n");
483         else
484           memset(x-4, 0xde, len+6);
485
486         TRACE("%p len=%u\n",x, len);
487
488         x -= 4;
489 #else
490         TRACE("%p\n",x);
491 #endif
492         return HeapFree(GetProcessHeap(), 0, x);
493 }
494
495 /*************************************************************************
496  * SHAlloc                                      [SHELL32.196]
497  *
498  * NOTES
499  *     void *task_alloc(DWORD len), uses SHMalloc allocator
500  *     exported by ordinal
501  */
502 LPVOID WINAPI SHAlloc(DWORD len) 
503 {
504         LPBYTE ret;
505
506 #if MEM_DEBUG
507         ret = (LPVOID) HeapAlloc(GetProcessHeap(),0,len+6);
508 #else
509         ret = (LPVOID) HeapAlloc(GetProcessHeap(),0,len);
510 #endif
511
512 #if MEM_DEBUG
513         *(LPWORD)(ret) = 0x8271;
514         *(LPWORD)(ret+2) = (WORD)len;
515         *(LPWORD)(ret+4+len) = 0x7384;
516         ret += 4;
517         memset(ret, 0xdf, len);
518 #endif
519         TRACE("%lu bytes at %p\n",len, ret);
520         return (LPVOID)ret;
521 }
522
523 /*************************************************************************
524  * SHRegisterDragDrop                           [SHELL32.86]
525  *
526  * NOTES
527  *     exported by ordinal
528  */
529 DWORD WINAPI SHRegisterDragDrop(HWND hWnd,IDropTarget * pDropTarget) 
530 {
531         FIXME("(0x%08x,%p):stub.\n", hWnd, pDropTarget);
532         return     RegisterDragDrop(hWnd, pDropTarget);
533 }
534
535 /*************************************************************************
536  * SHRevokeDragDrop                             [SHELL32.87]
537  *
538  * NOTES
539  *     exported by ordinal
540  */
541 DWORD WINAPI SHRevokeDragDrop(DWORD x) {
542     FIXME("(0x%08lx):stub.\n",x);
543     return 0;
544 }
545
546 /*************************************************************************
547  * SHDoDragDrop                                 [SHELL32.88]
548  *
549  * NOTES
550  *     exported by ordinal
551  */
552 DWORD WINAPI SHDoDragDrop(DWORD u, DWORD v, DWORD w, DWORD x, DWORD y, DWORD z) {
553     FIXME("(0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx):stub.\n",u,v,w,x,y,z);
554     return 0;
555 }
556
557 /*************************************************************************
558  * RunFileDlg                                   [SHELL32.61]
559  *
560  * NOTES
561  *     Original name: RunFileDlg (exported by ordinal)
562  */
563 DWORD WINAPI
564 RunFileDlg (HWND hwndOwner, DWORD dwParam1, DWORD dwParam2,
565             LPSTR lpszTitle, LPSTR lpszPrompt, UINT uFlags)
566 {
567     FIXME("(0x%08x 0x%lx 0x%lx \"%s\" \"%s\" 0x%x):stub.\n",
568            hwndOwner, dwParam1, dwParam2, lpszTitle, lpszPrompt, uFlags);
569     return 0;
570 }
571
572 /*************************************************************************
573  * ExitWindowsDialog                            [SHELL32.60]
574  *
575  * NOTES
576  *     exported by ordinal
577  */
578 void WINAPI ExitWindowsDialog (HWND hWndOwner)
579 {
580         TRACE("(0x%08x)\n", hWndOwner);
581         if (MessageBoxA( hWndOwner, "Do you want to exit WINE?", "Shutdown", MB_YESNO|MB_ICONQUESTION) == IDOK)
582         { SendMessageA ( hWndOwner, WM_QUIT, 0, 0);
583         }
584 }
585
586 /*************************************************************************
587  * ArrangeWindows                               [SHELL32.184]
588  * 
589  */
590 DWORD WINAPI
591 ArrangeWindows (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3,
592                 DWORD dwParam4, DWORD dwParam5)
593 {
594     FIXME("(0x%lx 0x%lx 0x%lx 0x%lx 0x%lx):stub.\n",
595            dwParam1, dwParam2, dwParam3, dwParam4, dwParam5);
596     return 0;
597 }
598
599 /*************************************************************************
600  * SignalFileOpen                               [SHELL32.103]
601  *
602  * NOTES
603  *     exported by ordinal
604  */
605 DWORD WINAPI
606 SignalFileOpen (DWORD dwParam1)
607 {
608     FIXME("(0x%08lx):stub.\n", dwParam1);
609
610     return 0;
611 }
612
613 /*************************************************************************
614  * SHAddToRecentDocs                            [SHELL32.234]
615  *
616  * PARAMETERS
617  *   uFlags  [IN] SHARD_PATH or SHARD_PIDL
618  *   pv      [IN] string or pidl, NULL clears the list
619  *
620  * NOTES
621  *     exported by name
622  */
623 DWORD WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)   
624 { if (SHARD_PIDL==uFlags)
625   { FIXME("(0x%08x,pidl=%p):stub.\n", uFlags,pv);
626         }
627         else
628         { FIXME("(0x%08x,%s):stub.\n", uFlags,(char*)pv);
629         }
630   return 0;
631 }
632 /*************************************************************************
633  * SHFileOperation                              [SHELL32.242]
634  *
635  */
636 DWORD WINAPI SHFileOperationAW(DWORD x)
637 {       FIXME("0x%08lx stub\n",x);
638         return 0;
639
640 }
641
642 /*************************************************************************
643  * SHFileOperationA                             [SHELL32.243]
644  *
645  * NOTES
646  *     exported by name
647  */
648 DWORD WINAPI SHFileOperationA (LPSHFILEOPSTRUCTA lpFileOp)   
649 { FIXME("(%p):stub.\n", lpFileOp);
650   return 1;
651 }
652 /*************************************************************************
653  * SHFileOperationW                             [SHELL32.244]
654  *
655  * NOTES
656  *     exported by name
657  */
658 DWORD WINAPI SHFileOperationW (LPSHFILEOPSTRUCTW lpFileOp)   
659 { FIXME("(%p):stub.\n", lpFileOp);
660   return 1;
661 }
662
663 /*************************************************************************
664  * SHChangeNotify                               [SHELL32.239]
665  *
666  * NOTES
667  *     exported by name
668  */
669 DWORD WINAPI SHChangeNotify (
670     INT   wEventId,  /* [IN] flags that specifies the event*/
671     UINT  uFlags,   /* [IN] the meaning of dwItem[1|2]*/
672                 LPCVOID dwItem1,
673                 LPCVOID dwItem2)
674 { FIXME("(0x%08x,0x%08ux,%p,%p):stub.\n", wEventId,uFlags,dwItem1,dwItem2);
675   return 0;
676 }
677 /*************************************************************************
678  * SHCreateShellFolderViewEx                    [SHELL32.174]
679  *
680  * NOTES
681  *  see IShellFolder::CreateViewObject
682  */
683 HRESULT WINAPI SHCreateShellFolderViewEx(
684   LPSHELLVIEWDATA psvcbi, /*[in ] shelltemplate struct*/
685   LPVOID* ppv)            /*[out] IShellView pointer*/
686 {
687         IShellView * psf;
688         HRESULT hRes;
689         
690         TRACE("sf=%p pidl=%p cb=%p mode=0x%08lx parm=0x%08lx\n", 
691           psvcbi->pShellFolder, psvcbi->pidl, psvcbi->pCallBack, psvcbi->viewmode, psvcbi->dwUserParam);
692
693         psf = IShellView_Constructor(psvcbi->pShellFolder);
694         
695         if (!psf)
696           return E_OUTOFMEMORY;
697
698         IShellView_AddRef(psf);
699         hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
700         IShellView_Release(psf);
701
702         return hRes;
703 }
704 /*************************************************************************
705  *  SHWinHelp                                   [SHELL32.127]
706  *
707  */
708 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
709 {       FIXME("0x%08lx 0x%08lx 0x%08lx 0x%08lx stub\n",v,w,x,z);
710         return 0;
711 }
712 /*************************************************************************
713  *  SHRunControlPanel [SHELL32.161]
714  *
715  */
716 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
717 {       FIXME("0x%08lx 0x%08lx stub\n",x,z);
718         return 0;
719 }
720 /*************************************************************************
721  * ShellExecuteEx                               [SHELL32.291]
722  *
723  */
724 BOOL WINAPI ShellExecuteExAW (LPVOID sei)
725 {       if (VERSION_OsIsUnicode())
726           return ShellExecuteExW (sei);
727         return ShellExecuteExA (sei);
728 }
729 /*************************************************************************
730  * ShellExecuteExA                              [SHELL32.292]
731  *
732  */
733 BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei)
734 {       CHAR szApplicationName[MAX_PATH],szCommandline[MAX_PATH],szPidl[20];
735         LPSTR pos;
736         int gap, len;
737         STARTUPINFOA  startupinfo;
738         PROCESS_INFORMATION processinformation;
739                         
740         WARN("mask=0x%08lx hwnd=0x%04x verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s incomplete\n",
741                 sei->fMask, sei->hwnd, sei->lpVerb, sei->lpFile,
742                 sei->lpParameters, sei->lpDirectory, sei->nShow, 
743                 (sei->fMask & SEE_MASK_CLASSNAME) ? sei->lpClass : "not used");
744
745         ZeroMemory(szApplicationName,MAX_PATH);
746         if (sei->lpFile)
747           strcpy(szApplicationName, sei->lpFile);
748         
749         ZeroMemory(szCommandline,MAX_PATH);
750         if (sei->lpParameters)
751           strcpy(szCommandline, sei->lpParameters);
752                         
753         if (sei->fMask & (SEE_MASK_CLASSKEY | SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY |
754                           SEE_MASK_NOCLOSEPROCESS | SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT |
755                           SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE | 
756                           SEE_MASK_NO_CONSOLE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR ))
757         { FIXME("flags ignored: 0x%08lx\n", sei->fMask);
758         }
759
760         if (sei->fMask & SEE_MASK_CLASSNAME)
761         { HCR_GetExecuteCommand(sei->lpClass, (sei->lpVerb) ? sei->lpVerb : "open", szCommandline, 256);            
762         }
763
764         /* process the IDList */
765         if ( (sei->fMask & SEE_MASK_INVOKEIDLIST) == SEE_MASK_INVOKEIDLIST) /*0x0c*/
766         { SHGetPathFromIDListA (sei->lpIDList,szApplicationName);
767           TRACE("-- idlist=%p (%s)\n", sei->lpIDList, szApplicationName);
768         }
769         else
770         { if (sei->fMask & SEE_MASK_IDLIST )
771           { /* %I is the adress of a global item ID*/
772             pos = strstr(szCommandline, "%I");
773             if (pos)
774             { HGLOBAL hmem = SHAllocShared ( sei->lpIDList, ILGetSize(sei->lpIDList), 0);
775               sprintf(szPidl,":%li",(DWORD)SHLockShared(hmem,0) );
776               SHUnlockShared(hmem);
777             
778               gap = strlen(szPidl);
779               len = strlen(pos)-2;
780               memmove(pos+gap,pos+2,len);
781               memcpy(pos,szPidl,gap);
782
783             }
784           }
785         }
786
787         pos = strstr(szCommandline, ",%L");     /* dunno what it means: kill it*/
788         if (pos)
789         { len = strlen(pos)-2;
790           *pos=0x0;
791           memmove(pos,pos+3,len);
792         }
793
794         TRACE("execute: %s %s\n",szApplicationName, szCommandline);
795
796         ZeroMemory(&startupinfo,sizeof(STARTUPINFOA));
797         startupinfo.cb = sizeof(STARTUPINFOA);
798
799         return CreateProcessA(szApplicationName[0] ? szApplicationName:NULL,
800                          szCommandline[0] ? szCommandline : NULL,
801                          NULL, NULL, FALSE, 0, 
802                          NULL, NULL, &startupinfo, &processinformation);
803           
804         
805 }
806 /*************************************************************************
807  * ShellExecuteExW                              [SHELL32.293]
808  *
809  */
810 BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei)
811 {       SHELLEXECUTEINFOA seiA;
812         DWORD ret;
813
814         TRACE("%p\n", sei);
815
816         memcpy(&seiA, sei, sizeof(SHELLEXECUTEINFOA));
817         
818         if (sei->lpVerb)
819           seiA.lpVerb = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpVerb);
820
821         if (sei->lpFile)
822           seiA.lpFile = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpFile);
823
824         if (sei->lpParameters)
825           seiA.lpParameters = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpParameters);
826
827         if (sei->lpDirectory)
828           seiA.lpDirectory = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpDirectory);
829
830         if ((sei->fMask & SEE_MASK_CLASSNAME) && sei->lpClass)
831           seiA.lpClass = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpClass);
832         else
833           seiA.lpClass = NULL;
834                   
835         ret = ShellExecuteExA(&seiA);
836
837         if (seiA.lpVerb)        HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpVerb );
838         if (seiA.lpFile)        HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpFile );
839         if (seiA.lpParameters)  HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpParameters );
840         if (seiA.lpDirectory)   HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpDirectory );
841         if (seiA.lpClass)       HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpClass );
842
843         return ret;
844 }
845
846 static LPUNKNOWN SHELL32_IExplorerInterface=0;
847 /*************************************************************************
848  * SHSetInstanceExplorer                        [SHELL32.176]
849  *
850  * NOTES
851  *  Sets the interface
852  */
853 HRESULT WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
854 {       TRACE("%p\n", lpUnknown);
855         SHELL32_IExplorerInterface = lpUnknown;
856         return (HRESULT) lpUnknown;
857 }
858 /*************************************************************************
859  * SHGetInstanceExplorer                        [SHELL32.256]
860  *
861  * NOTES
862  *  gets the interface pointer of the explorer and a reference
863  */
864 HRESULT WINAPI SHGetInstanceExplorer (LPUNKNOWN * lpUnknown)
865 {       TRACE("%p\n", lpUnknown);
866
867         *lpUnknown = SHELL32_IExplorerInterface;
868
869         if (!SHELL32_IExplorerInterface)
870           return E_FAIL;
871
872         IUnknown_AddRef(SHELL32_IExplorerInterface);
873         return NOERROR;
874 }
875 /*************************************************************************
876  * SHFreeUnusedLibraries                        [SHELL32.123]
877  *
878  * NOTES
879  *  exported by name
880  */
881 HRESULT WINAPI SHFreeUnusedLibraries (void)
882 {       FIXME("stub\n");
883         return TRUE;
884 }
885 /*************************************************************************
886  * DAD_SetDragImage                             [SHELL32.136]
887  *
888  * NOTES
889  *  exported by name
890  */
891 HRESULT WINAPI DAD_SetDragImage (DWORD u, DWORD v)
892 { FIXME("0x%08lx 0x%08lx stub\n",u, v);
893   return 0;
894 }
895 /*************************************************************************
896  * DAD_ShowDragImage                            [SHELL32.137]
897  *
898  * NOTES
899  *  exported by name
900  */
901 HRESULT WINAPI DAD_ShowDragImage (DWORD u)
902 { FIXME("0x%08lx stub\n",u);
903   return 0;
904 }
905 /*************************************************************************
906  * SHRegCloseKey                        [NT4.0:SHELL32.505]
907  *
908  */
909 HRESULT WINAPI SHRegCloseKey (HKEY hkey)
910 {       TRACE("0x%04x\n",hkey);
911         return RegCloseKey( hkey );
912 }
913 /*************************************************************************
914  * SHRegOpenKeyA                                [SHELL32.506]
915  *
916  */
917 HRESULT WINAPI SHRegOpenKeyA(HKEY hKey, LPSTR lpSubKey, LPHKEY phkResult)
918 {
919         TRACE("(0x%08x, %s, %p)\n", hKey, debugstr_a(lpSubKey), phkResult);
920         return RegOpenKeyA(hKey, lpSubKey, phkResult);
921 }
922
923 /*************************************************************************
924  * SHRegOpenKeyW                                [NT4.0:SHELL32.507]
925  *
926  */
927 HRESULT WINAPI SHRegOpenKeyW (HKEY hkey, LPCWSTR lpszSubKey, LPHKEY retkey)
928 {       WARN("0x%04x %s %p\n",hkey,debugstr_w(lpszSubKey),retkey);
929         return RegOpenKeyW( hkey, lpszSubKey, retkey );
930 }
931 /*************************************************************************
932  * SHRegQueryValueExA                           [SHELL32.509]
933  *
934  */
935 HRESULT WINAPI SHRegQueryValueExA(
936         HKEY hkey,
937         LPSTR lpValueName,
938         LPDWORD lpReserved,
939         LPDWORD lpType,
940         LPBYTE lpData,
941         LPDWORD lpcbData)
942 {
943         TRACE("0x%04x %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
944         return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
945 }
946 /*************************************************************************
947  * SHRegQueryValueW                             [NT4.0:SHELL32.510]
948  *
949  */
950 HRESULT WINAPI SHRegQueryValueW (HKEY hkey, LPWSTR lpszSubKey,
951                                  LPWSTR lpszData, LPDWORD lpcbData )
952 {       WARN("0x%04x %s %p %p semi-stub\n",
953                 hkey, debugstr_w(lpszSubKey), lpszData, lpcbData);
954         return RegQueryValueW( hkey, lpszSubKey, lpszData, lpcbData );
955 }
956
957 /*************************************************************************
958  * SHRegQueryValueExW                           [NT4.0:SHELL32.511]
959  *
960  * FIXME 
961  *  if the datatype REG_EXPAND_SZ then expand the string and change
962  *  *pdwType to REG_SZ. 
963  */
964 HRESULT WINAPI SHRegQueryValueExW (HKEY hkey, LPWSTR pszValue, LPDWORD pdwReserved,
965                  LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData)
966 {       DWORD ret;
967         WARN("0x%04x %s %p %p %p %p semi-stub\n",
968                 hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
969         ret = RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
970         return ret;
971 }
972
973 /*************************************************************************
974  * ReadCabinetState                             [NT 4.0:SHELL32.651]
975  *
976  */
977 HRESULT WINAPI ReadCabinetState(DWORD u, DWORD v)
978 {       FIXME("0x%04lx 0x%04lx stub\n",u,v);
979         return 0;
980 }
981 /*************************************************************************
982  * WriteCabinetState                            [NT 4.0:SHELL32.652]
983  *
984  */
985 HRESULT WINAPI WriteCabinetState(DWORD u)
986 {       FIXME("0x%04lx stub\n",u);
987         return 0;
988 }
989 /*************************************************************************
990  * FileIconInit                                 [SHELL32.660]
991  *
992  */
993 BOOL WINAPI FileIconInit(BOOL bFullInit)
994 {       FIXME("(%s)\n", bFullInit ? "true" : "false");
995         return 0;
996 }
997 /*************************************************************************
998  * IsUserAdmin                                  [NT 4.0:SHELL32.680]
999  *
1000  */
1001 HRESULT WINAPI IsUserAdmin(void)
1002 {       FIXME("stub\n");
1003         return TRUE;
1004 }
1005 /*************************************************************************
1006  * StrRetToStrN                                 [SHELL32.96]
1007  * 
1008  * converts a STRRET to a normal string
1009  *
1010  * NOTES
1011  *  the pidl is for STRRET OFFSET
1012  */
1013 HRESULT WINAPI StrRetToBufA (LPSTRRET src, LPITEMIDLIST pidl, LPSTR dest, DWORD len)
1014 {
1015         return StrRetToStrNA(dest, len, src, pidl);
1016 }
1017
1018 HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
1019 {
1020         TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
1021
1022         switch (src->uType)
1023         {
1024           case STRRET_WSTR:
1025             WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
1026             SHFree(src->u.pOleStr);
1027             break;
1028
1029           case STRRET_CSTRA:
1030             lstrcpynA((LPSTR)dest, src->u.cStr, len);
1031             break;
1032
1033           case STRRET_OFFSETA:
1034             lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
1035             break;
1036
1037           default:
1038             FIXME("unknown type!\n");
1039             if (len)
1040             {
1041               *(LPSTR)dest = '\0';
1042             }
1043             return(FALSE);
1044         }
1045         return S_OK;
1046 }
1047
1048 HRESULT WINAPI StrRetToBufW (LPSTRRET src, LPITEMIDLIST pidl, LPWSTR dest, DWORD len)
1049 {
1050         return StrRetToStrNW(dest, len, src, pidl);
1051 }
1052
1053 HRESULT WINAPI StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
1054 {
1055         TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
1056
1057         switch (src->uType)
1058         {
1059           case STRRET_WSTR:
1060             lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
1061             SHFree(src->u.pOleStr);
1062             break;
1063
1064           case STRRET_CSTRA:
1065             lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
1066             break;
1067
1068           case STRRET_OFFSETA:
1069             if (pidl)
1070             {
1071               lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
1072             }
1073             break;
1074
1075           default:
1076             FIXME("unknown type!\n");
1077             if (len)
1078             { *(LPSTR)dest = '\0';
1079             }
1080             return(FALSE);
1081         }
1082         return S_OK;
1083 }
1084 HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
1085 {
1086         if(VERSION_OsIsUnicode())
1087           return StrRetToStrNW (dest, len, src, pidl);
1088         return StrRetToStrNA (dest, len, src, pidl);
1089 }
1090
1091 /*************************************************************************
1092  * StrChrW                                      [NT 4.0:SHELL32.651]
1093  *
1094  */
1095 LPWSTR WINAPI StrChrW (LPWSTR str, WCHAR x )
1096 {       LPWSTR ptr=str;
1097         
1098         TRACE("%s 0x%04x\n",debugstr_w(str),x);
1099         do 
1100         {  if (*ptr==x)
1101            { return ptr;
1102            }
1103            ptr++;
1104         } while (*ptr);
1105         return NULL;
1106 }
1107
1108 /*************************************************************************
1109  * StrCmpNIW                                    [NT 4.0:SHELL32.*]
1110  *
1111  */
1112 INT WINAPI StrCmpNIW ( LPWSTR wstr1, LPWSTR wstr2, INT len)
1113 {       FIXME("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
1114         return 0;
1115 }
1116
1117 /*************************************************************************
1118  * SHAllocShared                                [SHELL32.520]
1119  *
1120  * NOTES
1121  *  parameter1 is return value from HeapAlloc
1122  *  parameter2 is equal to the size allocated with HeapAlloc
1123  *  parameter3 is return value from GetCurrentProcessId
1124  *
1125  *  the return value is posted as lParam with 0x402 (WM_USER+2) to somewhere
1126  *  WM_USER+2 could be the undocumented CWM_SETPATH
1127  *  the allocated memory contains a pidl
1128  */
1129 HGLOBAL WINAPI SHAllocShared(LPVOID psrc, DWORD size, DWORD procID)
1130 {       HGLOBAL hmem;
1131         LPVOID pmem;
1132         
1133         TRACE("ptr=%p size=0x%04lx procID=0x%04lx\n",psrc,size,procID);
1134         hmem = GlobalAlloc(GMEM_FIXED, size);
1135         if (!hmem)
1136           return 0;
1137         
1138         pmem =  GlobalLock (hmem);
1139
1140         if (! pmem)
1141           return 0;
1142           
1143         memcpy (pmem, psrc, size);
1144         GlobalUnlock(hmem); 
1145         return hmem;
1146 }
1147 /*************************************************************************
1148  * SHLockShared                                 [SHELL32.521]
1149  *
1150  * NOTES
1151  *  parameter1 is return value from SHAllocShared
1152  *  parameter2 is return value from GetCurrentProcessId
1153  *  the receiver of (WM_USER+2) trys to lock the HANDLE (?) 
1154  *  the returnvalue seems to be a memoryadress
1155  */
1156 LPVOID WINAPI SHLockShared(HANDLE hmem, DWORD procID)
1157 {       TRACE("handle=0x%04x procID=0x%04lx\n",hmem,procID);
1158         return GlobalLock(hmem);
1159 }
1160 /*************************************************************************
1161  * SHUnlockShared                               [SHELL32.522]
1162  *
1163  * NOTES
1164  *  parameter1 is return value from SHLockShared
1165  */
1166 BOOL WINAPI SHUnlockShared(HANDLE pmem)
1167 {       TRACE("handle=0x%04x\n",pmem);
1168         return GlobalUnlock(pmem); 
1169 }
1170 /*************************************************************************
1171  * SHFreeShared                                 [SHELL32.523]
1172  *
1173  * NOTES
1174  *  parameter1 is return value from SHAllocShared
1175  *  parameter2 is return value from GetCurrentProcessId
1176  */
1177 HANDLE WINAPI SHFreeShared(HANDLE hmem, DWORD procID)
1178 {       TRACE("handle=0x%04x 0x%04lx\n",hmem,procID);
1179         return GlobalFree(hmem);
1180 }
1181
1182 /*************************************************************************
1183  * SetAppStartingCursor                         [SHELL32.99]
1184  *
1185  */
1186 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1187 {       FIXME("hwnd=0x%04x 0x%04lx stub\n",u,v );
1188         return 0;
1189 }
1190 /*************************************************************************
1191  * SHLoadOLE                                    [SHELL32.151]
1192  *
1193  */
1194 HRESULT WINAPI SHLoadOLE(DWORD u)
1195 {       FIXME("0x%04lx stub\n",u);
1196         return S_OK;
1197 }
1198 /*************************************************************************
1199  * DriveType                                    [SHELL32.64]
1200  *
1201  */
1202 HRESULT WINAPI DriveType(DWORD u)
1203 {       FIXME("0x%04lx stub\n",u);
1204         return 0;
1205 }
1206 /*************************************************************************
1207  * SHAbortInvokeCommand                         [SHELL32.198]
1208  *
1209  */
1210 HRESULT WINAPI SHAbortInvokeCommand(void)
1211 {       FIXME("stub\n");
1212         return 1;
1213 }
1214 /*************************************************************************
1215  * SHOutOfMemoryMessageBox                      [SHELL32.126]
1216  *
1217  */
1218 HRESULT WINAPI SHOutOfMemoryMessageBox(DWORD u, DWORD v, DWORD w)
1219 {       FIXME("0x%04lx 0x%04lx 0x%04lx stub\n",u,v,w);
1220         return 0;
1221 }
1222 /*************************************************************************
1223  * SHFlushClipboard                             [SHELL32.121]
1224  *
1225  */
1226 HRESULT WINAPI SHFlushClipboard(void)
1227 {       FIXME("stub\n");
1228         return 1;
1229 }
1230 /*************************************************************************
1231  * StrRChrA                                     [SHELL32.346]
1232  *
1233  */
1234 LPSTR WINAPI StrRChrA(LPCSTR lpStart, LPCSTR lpEnd, DWORD wMatch)
1235 {
1236         if (!lpStart)
1237             return NULL;
1238
1239         /* if the end not given, search*/
1240         if (!lpEnd)
1241         { lpEnd=lpStart;
1242           while (*lpEnd) 
1243             lpEnd++;
1244         }
1245
1246         for (--lpEnd;lpStart <= lpEnd; lpEnd--)
1247             if (*lpEnd==(char)wMatch)
1248                 return (LPSTR)lpEnd;
1249
1250         return NULL;
1251 }
1252 /*************************************************************************
1253  * StrRChrW                                     [SHELL32.320]
1254  *
1255  */
1256 LPWSTR WINAPI StrRChrW(LPWSTR lpStart, LPWSTR lpEnd, DWORD wMatch)
1257 {       LPWSTR wptr=NULL;
1258         TRACE("%s %s 0x%04x\n",debugstr_w(lpStart),debugstr_w(lpEnd), (WCHAR)wMatch );
1259
1260         /* if the end not given, search*/
1261         if (!lpEnd)
1262         { lpEnd=lpStart;
1263           while (*lpEnd) 
1264             lpEnd++;
1265         }
1266
1267         do 
1268         { if (*lpStart==(WCHAR)wMatch)
1269             wptr = lpStart;
1270           lpStart++;  
1271         } while ( lpStart<=lpEnd ); 
1272         return wptr;
1273 }
1274 /*************************************************************************
1275 * StrFormatByteSize                             [SHLWAPI]
1276 */
1277 LPSTR WINAPI StrFormatByteSizeA ( DWORD dw, LPSTR pszBuf, UINT cchBuf )
1278 {       char buf[64];
1279         TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
1280         if ( dw<1024L )
1281         { sprintf (buf,"%3.1f bytes", (FLOAT)dw);
1282         }
1283         else if ( dw<1048576L)
1284         { sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
1285         }
1286         else if ( dw < 1073741824L)
1287         { sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
1288         }
1289         else
1290         { sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
1291         }
1292         lstrcpynA (pszBuf, buf, cchBuf);
1293         return pszBuf;  
1294 }
1295 LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf )
1296 {       char buf[64];
1297         TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
1298         if ( dw<1024L )
1299         { sprintf (buf,"%3.1f bytes", (FLOAT)dw);
1300         }
1301         else if ( dw<1048576L)
1302         { sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
1303         }
1304         else if ( dw < 1073741824L)
1305         { sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
1306         }
1307         else
1308         { sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
1309         }
1310         lstrcpynAtoW (pszBuf, buf, cchBuf);
1311         return pszBuf;  
1312 }
1313 /*************************************************************************
1314  * SHWaitForFileToOpen                          [SHELL32.97]
1315  *
1316  */
1317 HRESULT WINAPI SHWaitForFileToOpen(DWORD u, DWORD v, DWORD w)
1318 {       FIXME("0x%04lx 0x%04lx 0x%04lx stub\n",u,v,w);
1319         return 0;
1320 }
1321 /*************************************************************************
1322  * Control_FillCache_RunDLL                     [SHELL32.8]
1323  *
1324  */
1325 HRESULT WINAPI Control_FillCache_RunDLL(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
1326 {       FIXME("0x%04x 0x%04x 0x%04lx 0x%04lx stub\n",hWnd, hModule,w,x);
1327         return 0;
1328 }
1329 /*************************************************************************
1330  * RunDLL_CallEntry16                           [SHELL32.122]
1331  * the name is propably wrong
1332  */
1333 HRESULT WINAPI RunDLL_CallEntry16(DWORD v, DWORD w, DWORD x, DWORD y, DWORD z)
1334 {       FIXME("0x%04lx 0x%04lx 0x%04lx 0x%04lx 0x%04lx stub\n",v,w,x,y,z);
1335         return 0;
1336 }
1337
1338 /************************************************************************
1339  *      shell32_654                             [SHELL32.654]
1340  *
1341  * NOTES: first parameter seems to be a pointer (same as passed to WriteCabinetState)
1342  * second one could be a size (0x0c). The size is the same as the structure saved to
1343  * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1344  * I'm (js) guessing: this one is just ReadCabinetState ;-)
1345  */
1346 HRESULT WINAPI shell32_654 (DWORD x, DWORD y)
1347 {       FIXME("0x%08lx 0x%08lx stub\n",x,y);
1348         return 0;
1349 }
1350
1351 /************************************************************************
1352  *      RLBuildListOfPaths                      [SHELL32.146]
1353  *
1354  * NOTES
1355  *   builds a DPA
1356  */
1357 DWORD WINAPI RLBuildListOfPaths (void)
1358 {       FIXME("stub\n");
1359         return 0;
1360 }
1361 /************************************************************************
1362  *      StrToOleStr                     [SHELL32.163]
1363  *
1364  */
1365 int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
1366 {
1367         TRACE("(%p, %p %s)\n",
1368         lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
1369
1370         return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
1371
1372 }
1373 int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
1374 {
1375         TRACE("(%p, %p %s)\n",
1376         lpWideCharStr, lpWString, debugstr_w(lpWString));
1377
1378         if (lstrcpyW (lpWideCharStr, lpWString ))
1379         { return lstrlenW (lpWideCharStr);
1380         }
1381         return 0;
1382 }
1383
1384 BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
1385 {
1386         if (VERSION_OsIsUnicode())
1387           return StrToOleStrW (lpWideCharStr, lpString);
1388         return StrToOleStrA (lpWideCharStr, lpString);
1389 }
1390
1391 /************************************************************************
1392  *      SHValidateUNC                           [SHELL32.173]
1393  *
1394  */
1395 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1396 {
1397         FIXME("0x%08lx 0x%08lx 0x%08lx stub\n",x,y,z);
1398         return 0;
1399 }
1400
1401 /************************************************************************
1402  *      DoEnvironmentSubstW                     [SHELL32.53]
1403  *
1404  */
1405 HRESULT WINAPI DoEnvironmentSubstA(LPSTR x, LPSTR y)
1406 {
1407         FIXME("(%p %s, %p %s) stub\n", x, debugstr_a(x), y, debugstr_a(y));
1408         return 0;
1409 }
1410
1411 HRESULT WINAPI DoEnvironmentSubstW(LPWSTR x, LPWSTR y)
1412 {
1413         FIXME("(%p %s, %p %s) stub\n", x, debugstr_w(x), y, debugstr_w(y));
1414         return 0;
1415 }
1416
1417 HRESULT WINAPI DoEnvironmentSubstAW(LPVOID x, LPVOID y)
1418 {
1419         if (VERSION_OsIsUnicode())
1420           return DoEnvironmentSubstW(x, y);
1421         return DoEnvironmentSubstA(x, y);
1422 }
1423
1424 /*************************************************************************
1425  *      shell32_243                             [SHELL32.243]
1426  * 
1427  * Win98+ by-ordinal routine.  In Win98 this routine returns zero and
1428  * does nothing else.  Possibly this does something in NT or SHELL32 5.0?
1429  *
1430  */
1431
1432 BOOL WINAPI shell32_243(DWORD a, DWORD b) 
1433
1434   return FALSE; 
1435 }
1436
1437 /************************************************************************
1438  *      Win32DeleteFile                         [SHELL32.164]  
1439  *
1440  * Deletes a file.  Also triggers a change notify if one exists, but
1441  * that mechanism doesn't yet exist in Wine's SHELL32.
1442  *
1443  * FIXME:
1444  * Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be
1445  * ANSI.  Is this Unicode on NT?
1446  *
1447  */ 
1448
1449 BOOL WINAPI Win32DeleteFile(LPSTR fName)
1450 {
1451   FIXME("%p(%s): partial stub\n", fName, fName);
1452
1453   DeleteFileA(fName);
1454
1455   return TRUE;
1456 }
1457 /*
1458 LPSTR WINAPI StrCpyNA(LPSTR psz1, LPCSTR psz2, int cchMax)
1459 {
1460         return lstrcpynA(psz1, psz2, cchMax);
1461 }
1462
1463 LPWSTR WINAPI StrCpyNW(LPWSTR psz1, LPCWSTR psz2, int cchMax)
1464 {
1465         return lstrcpynW(psz1, psz2, cchMax);
1466 }
1467 */