Authors: Francis Beaudet <francis@macadamian.com>, Sylvain St-Germain <sylvain@macada...
[wine] / dlls / shell32 / shellord.c
1 /*
2  *                              Shell Ordinal Functions
3  *
4  * These are completely undocumented. The meaning of the functions changes
5  * between different OS versions (NT uses Unicode strings, 95 uses ASCII
6  * strings, etc. etc.)
7  * 
8  * They are just here so that explorer.exe and iexplore.exe can be tested.
9  *
10  * Copyright 1997 Marcus Meissner
11  *           1998 Jürgen Schmied
12  */
13 #include <stdlib.h>
14 #include <string.h>
15 #include <unistd.h>
16 #include <ctype.h>
17 #include "windows.h"
18 #include "winerror.h"
19 #include "file.h"
20 #include "shell.h"
21 #include "heap.h"
22 #include "module.h"
23 #include "neexe.h"
24 #include "resource.h"
25 #include "dlgs.h"
26 #include "win.h"
27 #include "cursoricon.h"
28 #include "interfaces.h"
29 #include "shlobj.h"
30 #include "debug.h"
31 #include "winreg.h"
32 #include "winnls.h"
33 #include "winversion.h"
34 #include "shell32_main.h"
35
36 /*************************************************************************
37  * SHChangeNotifyRegister [SHELL32.2]
38  * NOTES
39  *   Idlist is an array of structures and Count specifies how many items in the array
40  *   (usually just one I think).
41  */
42 DWORD WINAPI
43 SHChangeNotifyRegister(
44     HWND32 hwnd,
45     LONG events1,
46     LONG events2,
47     DWORD msg,
48     int count,
49     IDSTRUCT *idlist)
50 {       FIXME(shell,"(0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08x,%p):stub.\n",
51                 hwnd,events1,events2,msg,count,idlist);
52         return 0;
53 }
54 /*************************************************************************
55  * SHChangeNotifyDeregister [SHELL32.4]
56  */
57 DWORD WINAPI
58 SHChangeNotifyDeregister(LONG x1)
59 {       FIXME(shell,"(0x%08lx):stub.\n",x1);
60         return 0;
61 }
62
63 /*************************************************************************
64  * ParseField [SHELL32.58]
65  *
66  */
67 DWORD WINAPI ParseField(LPCSTR src,DWORD field,LPSTR dst,DWORD len) 
68 {       FIXME(shell,"(%s,0x%08lx,%p,%ld):stub.\n",src,field,dst,len);
69
70         if (!src || !src[0] || !dst || !len)
71           return 0;
72
73         if (field >1)
74         { field--;      
75           while (field)
76           { if (*src==0x0) return FALSE;
77             if (*src==',') field--;
78             src++;
79           }
80         }
81
82         while (*src!=0x00 && *src!=',' && len>0) 
83         { *dst=*src; dst++, src++; len--;
84         }
85         *dst=0x0;
86         
87         return TRUE;
88 }
89
90 /*************************************************************************
91  * PickIconDlg [SHELL32.62]
92  * 
93  */
94 DWORD WINAPI PickIconDlg(DWORD x,DWORD y,DWORD z,DWORD a) {
95         FIXME(shell,"(%08lx,%08lx,%08lx,%08lx):stub.\n",x,y,z,a);
96         return 0xffffffff;
97 }
98
99 /*************************************************************************
100  * GetFileNameFromBrowse [SHELL32.63]
101  * 
102  */
103 DWORD WINAPI GetFileNameFromBrowse(HWND32 howner, LPSTR targetbuf, DWORD len, DWORD x, LPCSTR suffix, LPCSTR y, LPCSTR cmd) {
104     FIXME(shell,"(%04x,%p,%ld,%08lx,%s,%s,%s):stub.\n",
105             howner,targetbuf,len,x,suffix,y,cmd
106     );
107     /* puts up a Open Dialog and requests input into targetbuf */
108     /* OFN_HIDEREADONLY|OFN_NOCHANGEDIR|OFN_FILEMUSTEXIST|OFN_unknown */
109     lstrcpy32A(targetbuf,"x:\\s3.exe");
110     return 1;
111 }
112
113 /*************************************************************************
114  * SHGetSettings [SHELL32.68]
115  * 
116  */
117 DWORD WINAPI SHGetSettings(DWORD x,DWORD y,DWORD z) {
118         FIXME(shell,"(0x%08lx,0x%08lx,0x%08lx):stub.\n",
119                 x,y,z
120         );
121         return 0;
122 }
123
124 /*************************************************************************
125  * Shell_GetCachedImageIndex [SHELL32.72]
126  *
127  */
128 void WINAPI Shell_GetCachedImageIndex(LPVOID x,DWORD y,DWORD z) 
129 {       if( VERSION_OsIsUnicode())
130         { FIXME(shell,"(L%s,%08lx,%08lx):stub.\n",debugstr_w((LPWSTR)x),y,z);
131         }
132         else
133         { FIXME(shell,"(%s,%08lx,%08lx):stub.\n",debugstr_a((LPSTR)x),y,z);
134         }
135 }
136
137 /*************************************************************************
138  * SHShellFolderView_Message [SHELL32.73]
139  *
140  * PARAMETERS
141  *  hwndCabinet defines the explorer cabinet window that contains the 
142  *              shellview you need to communicate with
143  *  uMsg        identifying the SFVM enum to perform
144  *  lParam
145  *
146  * NOTES
147  *  Message SFVM_REARRANGE = 1
148  *    This message gets sent when a column gets clicked to instruct the
149  *    shell view to re-sort the item list. lParam identifies the column
150  *    that was clicked.
151  */
152 int WINAPI SHShellFolderView_Message(HWND32 hwndCabinet,UINT32 uMsg,LPARAM lParam)
153 { FIXME(shell,"%04x %08ux %08lx stub\n",hwndCabinet,uMsg,lParam);
154   return 0;
155 }
156
157 /*************************************************************************
158  * OleStrToStrN  [SHELL32.78]
159  * 
160  * NOTES
161  *     exported by ordinal
162  * FIXME
163  *  wrong implemented OleStr is NOT wide string !!!! (jsch)
164  */
165 BOOL32 WINAPI
166 OleStrToStrN (LPSTR lpMulti, INT32 nMulti, LPCWSTR lpWide, INT32 nWide) {
167     return WideCharToMultiByte (0, 0, lpWide, nWide,
168         lpMulti, nMulti, NULL, NULL);
169 }
170
171 /*************************************************************************
172  * StrToOleStrN  [SHELL32.79]
173  *
174  * NOTES
175  *     exported by ordinal
176  * FIXME
177  *  wrong implemented OleStr is NOT wide string !!!! (jsch)
178 */
179 BOOL32 WINAPI
180 StrToOleStrN (LPWSTR lpWide, INT32 nWide, LPCSTR lpMulti, INT32 nMulti) {
181     return MultiByteToWideChar (0, 0, lpMulti, nMulti, lpWide, nWide);
182 }
183
184 /*************************************************************************
185  * SHCloneSpecialIDList [SHELL32.89]
186  * 
187  * PARAMETERS
188  *  hwndOwner   [in] 
189  *  nFolder     [in]    CSIDL_xxxxx ??
190  *
191  * RETURNS
192  *  pidl ??
193  * NOTES
194  *     exported by ordinal
195  */
196 LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND32 hwndOwner,DWORD nFolder,DWORD x3)
197 {       LPITEMIDLIST ppidl;
198         WARN(shell,"(hwnd=0x%x,csidl=0x%lx,0x%lx):semi-stub.\n",
199                                          hwndOwner,nFolder,x3);
200
201         SHGetSpecialFolderLocation(hwndOwner, nFolder, &ppidl);
202
203         return ppidl;
204 }
205
206
207 /*************************************************************************
208  * SHGetSpecialFolderPath [SHELL32.175]
209  * 
210  * NOTES
211  *     exported by ordinal
212  */
213 void WINAPI SHGetSpecialFolderPath(DWORD x1,DWORD x2,DWORD x3,DWORD x4) {
214     FIXME(shell,"(0x%04lx,0x%04lx,csidl=0x%04lx,0x%04lx):stub.\n",
215       x1,x2,x3,x4
216     );
217 }
218
219 /*************************************************************************
220  * RegisterShellHook [SHELL32.181]
221  *
222  * PARAMS
223  *      hwnd [I]  window handle
224  *      y    [I]  flag ????
225  * 
226  * NOTES
227  *     exported by ordinal
228  */
229 void WINAPI RegisterShellHook32(HWND32 hwnd, DWORD y) {
230     FIXME(shell,"(0x%08x,0x%08lx):stub.\n",hwnd,y);
231 }
232
233 /*************************************************************************
234  * ShellMessageBoxA [SHELL32.183]
235  *
236  * Format and output errormessage.
237  *
238  * NOTES
239  *     exported by ordinal
240  */
241 void __cdecl
242 ShellMessageBoxA(HMODULE32 hmod,HWND32 hwnd,DWORD id,DWORD x,DWORD type,LPVOID arglist) {
243         char    buf[100],buf2[100]/*,*buf3*/;
244 /*      LPVOID  args = &arglist;*/
245
246         if (!LoadString32A(hmod,x,buf,100))
247                 strcpy(buf,"Desktop");
248 //      LoadString32A(hmod,id,buf2,100);
249         /* FIXME: the varargs handling doesn't. */
250 //      FormatMessage32A(0x500,buf2,0,0,(LPSTR)&buf3,256,(LPDWORD)&args);
251
252         FIXME(shell,"(%08lx,%08lx,%08lx(%s),%08lx(%s),%08lx,%p):stub.\n",
253                 (DWORD)hmod,(DWORD)hwnd,id,buf2,x,buf,type,arglist
254         );
255         /*MessageBox32A(hwnd,buf3,buf,id|0x10000);*/
256 }
257
258 /*************************************************************************
259  * SHRestricted [SHELL32.100]
260  *
261  * walks through policy table, queries <app> key, <type> value, returns 
262  * queried (DWORD) value.
263  * {0x00001,Explorer,NoRun}
264  * {0x00002,Explorer,NoClose}
265  * {0x00004,Explorer,NoSaveSettings}
266  * {0x00008,Explorer,NoFileMenu}
267  * {0x00010,Explorer,NoSetFolders}
268  * {0x00020,Explorer,NoSetTaskbar}
269  * {0x00040,Explorer,NoDesktop}
270  * {0x00080,Explorer,NoFind}
271  * {0x00100,Explorer,NoDrives}
272  * {0x00200,Explorer,NoDriveAutoRun}
273  * {0x00400,Explorer,NoDriveTypeAutoRun}
274  * {0x00800,Explorer,NoNetHood}
275  * {0x01000,Explorer,NoStartBanner}
276  * {0x02000,Explorer,RestrictRun}
277  * {0x04000,Explorer,NoPrinterTabs}
278  * {0x08000,Explorer,NoDeletePrinter}
279  * {0x10000,Explorer,NoAddPrinter}
280  * {0x20000,Explorer,NoStartMenuSubFolders}
281  * {0x40000,Explorer,MyDocsOnNet}
282  * {0x80000,WinOldApp,NoRealMode}
283  *
284  * NOTES
285  *     exported by ordinal
286  */
287 DWORD WINAPI SHRestricted (DWORD pol) {
288         HKEY    xhkey;
289
290         FIXME(shell,"(%08lx):stub.\n",pol);
291         if (RegOpenKey32A(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies",&xhkey))
292                 return 0;
293         /* FIXME: do nothing for now, just return 0 (== "allowed") */
294         RegCloseKey(xhkey);
295         return 0;
296 }
297
298 /*************************************************************************
299  * SHCreateDirectory [SHELL32.165]
300  *
301  * NOTES
302  *  exported by ordinal
303  *  not sure about LPSECURITY_ATTRIBUTES
304  */
305 DWORD WINAPI SHCreateDirectory(LPSECURITY_ATTRIBUTES sec,LPCSTR path) {
306         TRACE(shell,"(%p,%s):stub.\n",sec,path);
307         if (CreateDirectory32A(path,sec))
308                 return TRUE;
309         /* SHChangeNotify(8,1,path,0); */
310         return FALSE;
311 #if 0
312         if (SHELL32_79(path,(LPVOID)x))
313                 return 0;
314         FIXME(shell,"(%08lx,%s):stub.\n",x,path);
315         return 0;
316 #endif
317 }
318
319 /*************************************************************************
320  * SHFree [SHELL32.195]
321  *
322  * NOTES
323  *     free_ptr() - frees memory using IMalloc
324  *     exported by ordinal
325  */
326 DWORD WINAPI SHFree(LPVOID x) {
327   TRACE(shell,"%p\n",x);
328   /*return LocalFree32((HANDLE32)x);*/ /* crashes */
329   return HeapFree(GetProcessHeap(),0,x);
330 }
331
332 /*************************************************************************
333  * SHAlloc [SHELL32.196]
334  *
335  * NOTES
336  *     void *task_alloc(DWORD len), uses SHMalloc allocator
337  *     exported by ordinal
338  */
339 LPVOID WINAPI SHAlloc(DWORD len) {
340  /* void * ret = (LPVOID)LocalAlloc32(len,LMEM_ZEROINIT);*/ /* chrashes */
341  void * ret = (LPVOID) HeapAlloc(GetProcessHeap(),0,len);
342   TRACE(shell,"%lu bytes at %p\n",len, ret);
343   return ret;
344 }
345
346 /*************************************************************************
347  * OpenRegStream [SHELL32.85]
348  *
349  * NOTES
350  *     exported by ordinal
351  */
352 DWORD WINAPI OpenRegStream(DWORD x1,DWORD x2,DWORD x3,DWORD x4) {
353     FIXME(shell,"(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub.\n",
354         x1,x2,x3,x4
355     );
356     return 0;
357 }
358
359 /*************************************************************************
360  * SHRegisterDragDrop [SHELL32.86]
361  *
362  * NOTES
363  *     exported by ordinal
364  */
365 DWORD WINAPI SHRegisterDragDrop(HWND32 hwnd,DWORD x2) {
366     FIXME (shell, "(0x%08x,0x%08lx):stub.\n", hwnd, x2);
367     return 0;
368 }
369
370 /*************************************************************************
371  * SHRevokeDragDrop [SHELL32.87]
372  *
373  * NOTES
374  *     exported by ordinal
375  */
376 DWORD WINAPI SHRevokeDragDrop(DWORD x) {
377     FIXME(shell,"(0x%08lx):stub.\n",x);
378     return 0;
379 }
380
381 /*************************************************************************
382  * RunFileDlg [SHELL32.61]
383  *
384  * NOTES
385  *     Original name: RunFileDlg (exported by ordinal)
386  */
387 DWORD WINAPI
388 RunFileDlg (HWND32 hwndOwner, DWORD dwParam1, DWORD dwParam2,
389             LPSTR lpszTitle, LPSTR lpszPrompt, UINT32 uFlags)
390 {
391     FIXME (shell,"(0x%08x 0x%lx 0x%lx \"%s\" \"%s\" 0x%x):stub.\n",
392            hwndOwner, dwParam1, dwParam2, lpszTitle, lpszPrompt, uFlags);
393     return 0;
394 }
395
396 /*************************************************************************
397  * ExitWindowsDialog [SHELL32.60]
398  *
399  * NOTES
400  *     exported by ordinal
401  */
402 DWORD WINAPI
403 ExitWindowsDialog (HWND32 hwndOwner)
404 {
405     FIXME (shell,"(0x%08x):stub.\n", hwndOwner);
406     return 0;
407 }
408
409 /*************************************************************************
410  * ArrangeWindows [SHELL32.184]
411  * 
412  */
413 DWORD WINAPI
414 ArrangeWindows (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3,
415                 DWORD dwParam4, DWORD dwParam5)
416 {
417     FIXME (shell,"(0x%lx 0x%lx 0x%lx 0x%lx 0x%lx):stub.\n",
418            dwParam1, dwParam2, dwParam3, dwParam4, dwParam5);
419     return 0;
420 }
421
422 /*************************************************************************
423  * SHCLSIDFromString [SHELL32.147]
424  *
425  * NOTES
426  *     exported by ordinal
427  */
428 DWORD WINAPI
429 SHCLSIDFromString (DWORD dwParam1, DWORD dwParam2)
430 {
431     FIXME (shell,"(0x%lx 0x%lx):stub.\n", dwParam1, dwParam2);
432     FIXME (shell,"(\"%s\" \"%s\"):stub.\n", (LPSTR)dwParam1, (LPSTR)dwParam2);
433
434     return 0;
435 }
436
437
438 /*************************************************************************
439  * SignalFileOpen [SHELL32.103]
440  *
441  * NOTES
442  *     exported by ordinal
443  */
444 DWORD WINAPI
445 SignalFileOpen (DWORD dwParam1)
446 {
447     FIXME (shell,"(0x%08lx):stub.\n", dwParam1);
448
449     return 0;
450 }
451
452 /*************************************************************************
453  * SHAddToRecentDocs [SHELL32.234]
454  *
455  * PARAMETERS
456  *   uFlags  [IN] SHARD_PATH or SHARD_PIDL
457  *   pv      [IN] string or pidl, NULL clears the list
458  *
459  * NOTES
460  *     exported by name
461  */
462 DWORD WINAPI SHAddToRecentDocs32 (UINT32 uFlags,LPCVOID pv)   
463 { if (SHARD_PIDL==uFlags)
464   { FIXME (shell,"(0x%08x,pidl=%p):stub.\n", uFlags,pv);
465         }
466         else
467         { FIXME (shell,"(0x%08x,%s):stub.\n", uFlags,(char*)pv);
468         }
469   return 0;
470 }
471 /*************************************************************************
472  * SHFileOperation32 [SHELL32.242]
473  *
474  */
475 DWORD WINAPI SHFileOperation32(DWORD x)
476 {       FIXME(shell,"0x%08lx stub\n",x);
477         return 0;
478
479 }
480
481 /*************************************************************************
482  * SHFileOperation32A [SHELL32.243]
483  *
484  * NOTES
485  *     exported by name
486  */
487 DWORD WINAPI SHFileOperation32A (LPSHFILEOPSTRUCT32A lpFileOp)   
488 { FIXME (shell,"(%p):stub.\n", lpFileOp);
489   return 1;
490 }
491 /*************************************************************************
492  * SHFileOperation32W [SHELL32.244]
493  *
494  * NOTES
495  *     exported by name
496  */
497 DWORD WINAPI SHFileOperation32W (LPSHFILEOPSTRUCT32W lpFileOp)   
498 { FIXME (shell,"(%p):stub.\n", lpFileOp);
499   return 1;
500 }
501
502 /*************************************************************************
503  * SHChangeNotify [SHELL32.239]
504  *
505  * NOTES
506  *     exported by name
507  */
508 DWORD WINAPI SHChangeNotify32 (
509     INT32   wEventId,  /* [IN] flags that specifies the event*/
510     UINT32  uFlags,   /* [IN] the meaning of dwItem[1|2]*/
511                 LPCVOID dwItem1,
512                 LPCVOID dwItem2)
513 { FIXME (shell,"(0x%08x,0x%08ux,%p,%p):stub.\n", wEventId,uFlags,dwItem1,dwItem2);
514   return 0;
515 }
516 /*************************************************************************
517  * SHCreateShellFolderViewEx [SHELL32.174]
518  *
519  * NOTES
520  *  see IShellFolder::CreateViewObject
521  */
522 HRESULT WINAPI SHCreateShellFolderViewEx32(
523   LPSHELLVIEWDATA psvcbi, /*[in ] shelltemplate struct*/
524   LPVOID* ppv)            /*[out] IShellView pointer*/
525 { FIXME (shell,"(%p,%p):stub.\n", psvcbi,ppv);
526   return 0;
527 }
528 /*************************************************************************
529  * SHFind_InitMenuPopup [SHELL32.149]
530  *
531  * NOTES
532  *  Registers the menu behind the "Start" button
533  *
534  * PARAMETERS
535  *  hMenu               [in] handel of menu previously created
536  *  hWndParent  [in] parent window
537  *  w                   [in] no pointer
538  *  x                   [in] no pointer
539  */
540 HRESULT WINAPI SHFind_InitMenuPopup (HMENU32 hMenu, HWND32 hWndParent, DWORD w, DWORD x)
541 {       FIXME(shell,"hmenu=0x%08x hwnd=0x%08x 0x%08lx 0x%08lx stub\n",
542                 hMenu,hWndParent,w,x);
543         return 0;
544 }
545 /*************************************************************************
546  * FileMenu_InitMenuPopup [SHELL32.109]
547  *
548  */
549 HRESULT WINAPI FileMenu_InitMenuPopup (DWORD hmenu)
550 {       FIXME(shell,"hmenu=0x%lx stub\n",hmenu);
551         return 0;
552 }
553 /*************************************************************************
554  * FileMenu_Create [SHELL32.114]
555  *
556  * w retval from LoadBitmapA
557  *
558  *
559  */
560 HRESULT WINAPI FileMenu_Create (DWORD u, DWORD v, DWORD w, DWORD x, DWORD z)
561 { FIXME(shell,"0x%08lx 0x%08lx hbmp=0x%lx 0x%08lx 0x%08lx stub\n",u,v,w,x,z);
562   return 0;
563 }
564 /*************************************************************************
565  * FileMenu_TrackPopupMenuEx [SHELL32.116]
566  *
567  * PARAMETERS
568  *  uFlags              [in]    according to TrackPopupMenuEx
569  *  posX                [in]
570  *  posY                [in]
571  *  hWndParent          [in]
572  *  z   could be rect (trace) or TPMPARAMS (TrackPopupMenuEx)
573  */
574 HRESULT WINAPI FileMenu_TrackPopupMenuEx (DWORD t, DWORD uFlags, DWORD posX, DWORD posY, HWND32 hWndParent, DWORD z)
575 {       FIXME(shell,"0x%lx flags=0x%lx posx=0x%lx posy=0x%lx hwndp=0x%x 0x%lx stub\n",
576                 t,uFlags,posX,posY, hWndParent,z);
577         return 0;
578 }
579 /*************************************************************************
580  *  SHWinHelp [SHELL32.127]
581  *
582  */
583 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
584 {       FIXME(shell,"0x%08lx 0x%08lx 0x%08lx 0x%08lx stub\n",v,w,x,z);
585         return 0;
586 }
587 /*************************************************************************
588  *  SHRunControlPanel [SHELL32.161]
589  *
590  */
591 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
592 {       FIXME(shell,"0x%08lx 0x%08lx stub\n",x,z);
593         return 0;
594 }
595 /*************************************************************************
596  * ShellExecuteEx [SHELL32.291]
597  *
598  */
599 BOOL32 WINAPI ShellExecuteEx32 (LPVOID sei)
600 {       if (VERSION_OsIsUnicode())
601           return ShellExecuteEx32W (sei);
602         return ShellExecuteEx32A (sei);
603 }
604 /*************************************************************************
605  * ShellExecuteEx32A [SHELL32.292]
606  *
607  */
608 BOOL32 WINAPI ShellExecuteEx32A (LPSHELLEXECUTEINFO32A sei)
609 {       CHAR szTemp[MAX_PATH];
610
611         FIXME(shell,"(%p): stub\n",sei);
612
613         if (sei->fMask & SEE_MASK_IDLIST)
614         { SHGetPathFromIDList32A (sei->lpIDList,szTemp);
615           TRACE (shell,"-- idlist=%p (%s)\n", sei->lpIDList, szTemp);
616         }
617
618         if (sei->fMask & SEE_MASK_CLASSNAME)
619         { TRACE (shell,"-- classname= %s\n", sei->lpClass);
620         }
621     
622         if (sei->lpVerb)
623         { TRACE (shell,"-- action=%s\n", sei->lpVerb);
624         }
625         
626         return 0;
627 }
628 /*************************************************************************
629  * ShellExecuteEx [SHELL32.293]
630  *
631  */
632 BOOL32 WINAPI ShellExecuteEx32W (LPSHELLEXECUTEINFO32W sei)
633 {       WCHAR szTemp[MAX_PATH];
634
635         FIXME(shell,"(%p): stub\n",sei);
636
637         if (sei->fMask & SEE_MASK_IDLIST)
638         { SHGetPathFromIDList32W (sei->lpIDList,szTemp);
639           TRACE (shell,"-- idlist=%p (%s)\n", sei->lpIDList, debugstr_w(szTemp));
640         }
641
642         if (sei->fMask & SEE_MASK_CLASSNAME)
643         { TRACE (shell,"-- classname= %s\n", debugstr_w(sei->lpClass));
644         }
645     
646         if (sei->lpVerb)
647         { TRACE (shell,"-- action=%s\n", debugstr_w(sei->lpVerb));
648         }
649         
650         return 0;
651 }
652 static LPUNKNOWN SHELL32_IExplorerInterface=0;
653 /*************************************************************************
654  * SHSetInstanceExplorer [SHELL32.176]
655  *
656  * NOTES
657  *  Sets the interface
658  */
659 HRESULT WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
660 {       TRACE (shell,"%p\n", lpUnknown);
661         SHELL32_IExplorerInterface = lpUnknown;
662         return (HRESULT) lpUnknown;
663 }
664 /*************************************************************************
665  * SHGetInstanceExplorer [SHELL32.256]
666  *
667  * NOTES
668  *  gets the interface pointer of the explorer and a reference
669  */
670 HRESULT WINAPI SHGetInstanceExplorer (LPUNKNOWN * lpUnknown)
671 {       TRACE(shell,"%p\n", lpUnknown);
672
673         *lpUnknown = SHELL32_IExplorerInterface;
674
675         if (!SHELL32_IExplorerInterface)
676           return E_FAIL;
677
678         SHELL32_IExplorerInterface->lpvtbl->fnAddRef(SHELL32_IExplorerInterface);
679         return NOERROR;
680 }
681 /*************************************************************************
682  * SHFreeUnusedLibraries [SHELL32.123]
683  *
684  * NOTES
685  *  exported by name
686  */
687 HRESULT WINAPI SHFreeUnusedLibraries (void)
688 {       FIXME(shell,"stub\n");
689         return TRUE;
690 }
691 /*************************************************************************
692  * DAD_ShowDragImage [SHELL32.137]
693  *
694  * NOTES
695  *  exported by name
696  */
697 HRESULT WINAPI DAD_ShowDragImage (DWORD u)
698 { FIXME(shell,"0x%08lx stub\n",u);
699   return 0;
700 }
701 /*************************************************************************
702  * FileMenu_Destroy [SHELL32.118]
703  *
704  * NOTES
705  *  exported by name
706  */
707 HRESULT WINAPI FileMenu_Destroy (DWORD u)
708 { FIXME(shell,"0x%08lx stub\n",u);
709   return 0;
710 }
711 /*************************************************************************
712  * SHGetDataFromIDListA [SHELL32.247]
713  *
714  */
715 HRESULT WINAPI SHGetDataFromIDListA(DWORD u, DWORD v, DWORD w, DWORD x, DWORD y)
716 {       FIXME(shell,"0x%04lx 0x%04lx 0x%04lx 0x%04lx 0x%04lx stub\n",u,v,w,x,y);
717         return 0;
718 }
719 /*************************************************************************
720  * SHRegCloseKey32 [NT4.0:SHELL32.505]
721  *
722  */
723 HRESULT WINAPI SHRegCloseKey32 (HKEY hkey)
724 {       TRACE(shell,"0x%04x\n",hkey);
725         return RegCloseKey( hkey );
726 }
727 /*************************************************************************
728  * SHRegOpenKey32A [SHELL32.506]
729  *
730  */
731 HRESULT WINAPI SHRegOpenKey32A(HKEY hKey, LPSTR lpSubKey, LPHKEY phkResult)
732 {       FIXME(shell,"(0x%08x, %s, %p)\n", hKey, debugstr_a(lpSubKey),
733               phkResult);
734         return RegOpenKey32A(hKey, lpSubKey, phkResult);
735 }
736
737 /*************************************************************************
738  * SHRegOpenKey32W [NT4.0:SHELL32.507]
739  *
740  */
741 HRESULT WINAPI SHRegOpenKey32W (HKEY hkey, LPCWSTR lpszSubKey, LPHKEY retkey)
742 {       WARN(shell,"0x%04x %s %p\n",hkey,debugstr_w(lpszSubKey),retkey);
743         return RegOpenKey32W( hkey, lpszSubKey, retkey );
744 }
745 /*************************************************************************
746  * SHRegQueryValueExA [SHELL32.509]
747  *
748  */
749 HRESULT WINAPI SHRegQueryValueEx32A(DWORD u, LPSTR v, DWORD w, DWORD x,
750                                   DWORD y, DWORD z)
751 {       FIXME(shell,"0x%04lx %s 0x%04lx 0x%04lx 0x%04lx  0x%04lx stub\n",
752                 u,debugstr_a(v),w,x,y,z);
753         return 0;
754 }
755 /*************************************************************************
756  * SHRegQueryValue32W [NT4.0:SHELL32.510]
757  *
758  */
759 HRESULT WINAPI SHRegQueryValue32W (HKEY hkey, LPWSTR lpszSubKey,
760                                  LPWSTR lpszData, LPDWORD lpcbData )
761 {       WARN(shell,"0x%04x %s %p %p semi-stub\n",
762                 hkey, debugstr_w(lpszSubKey), lpszData, lpcbData);
763         return RegQueryValue32W( hkey, lpszSubKey, lpszData, lpcbData );
764 }
765
766 /*************************************************************************
767  * SHRegQueryValueEx32W [NT4.0:SHELL32.511]
768  *
769  * FIXME 
770  *  if the datatype REG_EXPAND_SZ then expand the string and change
771  *  *pdwType to REG_SZ. 
772  */
773 HRESULT WINAPI SHRegQueryValueEx32W (HKEY hkey, LPWSTR pszValue, LPDWORD pdwReserved,
774                  LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData)
775 {       DWORD ret;
776         WARN(shell,"0x%04x %s %p %p %p %p semi-stub\n",
777                 hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
778         ret = RegQueryValueEx32W ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
779         return ret;
780 }
781
782 /*************************************************************************
783  * ReadCabinetState [NT 4.0:SHELL32.651]
784  *
785  */
786 HRESULT WINAPI ReadCabinetState(DWORD u, DWORD v)
787 {       FIXME(shell,"0x%04lx 0x%04lx stub\n",u,v);
788         return 0;
789 }
790 /*************************************************************************
791  * WriteCabinetState [NT 4.0:SHELL32.652]
792  *
793  */
794 HRESULT WINAPI WriteCabinetState(DWORD u)
795 {       FIXME(shell,"0x%04lx stub\n",u);
796         return 0;
797 }
798 /*************************************************************************
799  * FileIconInit [SHELL32.660]
800  *
801  */
802 BOOL32 WINAPI FileIconInit(BOOL32 bFullInit)
803 {       FIXME(shell,"(%s)\n", bFullInit ? "true" : "false");
804         return 0;
805 }
806 /*************************************************************************
807  * IsUserAdmin [NT 4.0:SHELL32.680]
808  *
809  */
810 HRESULT WINAPI IsUserAdmin(void)
811 {       FIXME(shell,"stub\n");
812         return TRUE;
813 }
814 /*************************************************************************
815  * StrRetToStrN [SHELL32.96]
816  * 
817  * converts a STRRET to a normal string
818  *
819  * NOTES
820  *  FIXME the string handling is to simple (different STRRET choices)
821  *  at the moment only CSTR
822  *  the pidl is for STRRET OFFSET
823  */
824 HRESULT WINAPI StrRetToStrN (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
825 {       TRACE(shell,"dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
826
827         switch (src->uType)
828         { case STRRET_WSTR:
829             WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
830             SHFree(src->u.pOleStr);
831             break;
832
833           case STRRET_CSTRA:
834             if (VERSION_OsIsUnicode())
835               lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
836             else
837               strncpy((LPSTR)dest, src->u.cStr, len);
838             break;
839
840           case STRRET_OFFSETA:
841             if (pidl)
842             { if(VERSION_OsIsUnicode())
843                 lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
844               else
845                 strncpy((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
846               break;
847             }
848
849           default:
850             FIXME(shell,"unknown type!\n");
851             if (len)
852             { *(LPSTR)dest = '\0';
853             }
854             return(FALSE);
855         }
856         return(TRUE);
857 }
858
859 /*************************************************************************
860  * StrChrW [NT 4.0:SHELL32.651]
861  *
862  */
863 LPWSTR WINAPI StrChrW (LPWSTR str, WCHAR x )
864 {       LPWSTR ptr=str;
865         
866         TRACE(shell,"%s 0x%04x\n",debugstr_w(str),x);
867         do 
868         {  if (*ptr==x)
869            { return ptr;
870            }
871            ptr++;
872         } while (*ptr);
873         return NULL;
874 }
875
876 /*************************************************************************
877  *      StrCmpNIW               [NT 4.0:SHELL32.*]
878  *
879  */
880 INT32 WINAPI StrCmpNIW ( LPWSTR wstr1, LPWSTR wstr2, INT32 len)
881 {       FIXME( shell,"%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
882         return 0;
883 }
884
885 /*************************************************************************
886  * SHAllocShared [SHELL32.520]
887  *
888  * NOTES
889  *  parameter1 is return value from HeapAlloc
890  *  parameter2 is equal to the size allocated with HeapAlloc
891  *  parameter3 is return value from GetCurrentProcessId
892  *
893  *  the return value is posted as lParam with 0x402 (WM_USER+2) to somewhere
894  *  WM_USER+2 could be the undocumented CWM_SETPATH
895  *  the allocated memory contains a pidl
896  */
897 HGLOBAL32 WINAPI SHAllocShared(LPVOID psrc, DWORD size, DWORD procID)
898 {       HGLOBAL32 hmem;
899         LPVOID pmem;
900         
901         TRACE(shell,"ptr=%p size=0x%04lx procID=0x%04lx\n",psrc,size,procID);
902         hmem = GlobalAlloc32(GMEM_FIXED, size);
903         if (!hmem)
904           return 0;
905         
906         pmem =  GlobalLock32 (hmem);
907
908         if (! pmem)
909           return 0;
910           
911         memcpy (pmem, psrc, size);
912         GlobalUnlock32(hmem); 
913         return hmem;
914 }
915 /*************************************************************************
916  * SHLockShared [SHELL32.521]
917  *
918  * NOTES
919  *  parameter1 is return value from SHAllocShared
920  *  parameter2 is return value from GetCurrentProcessId
921  *  the receiver of (WM_USER+2) trys to lock the HANDLE (?) 
922  *  the returnvalue seems to be a memoryadress
923  */
924 LPVOID WINAPI SHLockShared(HANDLE32 hmem, DWORD procID)
925 {       TRACE(shell,"handle=0x%04x procID=0x%04lx\n",hmem,procID);
926         return GlobalLock32(hmem);
927 }
928 /*************************************************************************
929  * SHUnlockShared [SHELL32.522]
930  *
931  * NOTES
932  *  parameter1 is return value from SHLockShared
933  */
934 BOOL32 WINAPI SHUnlockShared(HANDLE32 pmem)
935 {       TRACE(shell,"handle=0x%04x\n",pmem);
936         return GlobalUnlock32(pmem); 
937 }
938 /*************************************************************************
939  * SHFreeShared [SHELL32.523]
940  *
941  * NOTES
942  *  parameter1 is return value from SHAllocShared
943  *  parameter2 is return value from GetCurrentProcessId
944  */
945 HANDLE32 WINAPI SHFreeShared(HANDLE32 hmem, DWORD procID)
946 {       TRACE(shell,"handle=0x%04x 0x%04lx\n",hmem,procID);
947         return GlobalFree32(hmem);
948 }
949
950 /*************************************************************************
951  * SetAppStartingCursor32 [SHELL32.99]
952  *
953  */
954 HRESULT WINAPI SetAppStartingCursor32(DWORD u, DWORD v)
955 {       FIXME(shell,"0x%04lx 0x%04lx stub\n",u,v );
956         return 0;
957 }
958 /*************************************************************************
959  * SHLoadOLE32 [SHELL32.151]
960  *
961  */
962 HRESULT WINAPI SHLoadOLE32(DWORD u)
963 {       FIXME(shell,"0x%04lx stub\n",u);
964         return S_OK;
965 }
966 /*************************************************************************
967  * Shell_MergeMenus32 [SHELL32.67]
968  *
969  */
970 BOOL32 _SHIsMenuSeparator(HMENU32 hm, int i)
971 {
972         MENUITEMINFO32A mii;
973
974         mii.cbSize = sizeof(MENUITEMINFO32A);
975         mii.fMask = MIIM_TYPE;
976         mii.cch = 0;    /* WARNING: We MUST initialize it to 0*/
977         if (!GetMenuItemInfo32A(hm, i, TRUE, &mii))
978         { return(FALSE);
979         }
980
981         if (mii.fType & MFT_SEPARATOR)
982         { return(TRUE);
983         }
984
985         return(FALSE);
986 }
987 #define MM_ADDSEPARATOR         0x00000001L
988 #define MM_SUBMENUSHAVEIDS      0x00000002L
989 HRESULT WINAPI Shell_MergeMenus32 (HMENU32 hmDst, HMENU32 hmSrc, UINT32 uInsert, UINT32 uIDAdjust, UINT32 uIDAdjustMax, ULONG uFlags)
990 {       int             nItem;
991         HMENU32         hmSubMenu;
992         BOOL32          bAlreadySeparated;
993         MENUITEMINFO32A miiSrc;
994         char            szName[256];
995         UINT32          uTemp, uIDMax = uIDAdjust;
996
997         FIXME(shell,"hmenu1=0x%04x hmenu2=0x%04x 0x%04x 0x%04x 0x%04x  0x%04lx stub\n",
998                  hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags);
999
1000         if (!hmDst || !hmSrc)
1001         { return uIDMax;
1002         }
1003
1004         nItem = GetMenuItemCount32(hmDst);
1005         if (uInsert >= (UINT32)nItem)
1006         { uInsert = (UINT32)nItem;
1007           bAlreadySeparated = TRUE;
1008         }
1009         else
1010         { bAlreadySeparated = _SHIsMenuSeparator(hmDst, uInsert);;
1011         }
1012         if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated)
1013         { /* Add a separator between the menus */
1014           InsertMenu32A(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
1015           bAlreadySeparated = TRUE;
1016         }
1017
1018
1019         /* Go through the menu items and clone them*/
1020         for (nItem = GetMenuItemCount32(hmSrc) - 1; nItem >= 0; nItem--)
1021         { miiSrc.cbSize = sizeof(MENUITEMINFO32A);
1022           miiSrc.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS | MIIM_TYPE | MIIM_DATA;
1023           /* We need to reset this every time through the loop in case
1024           menus DON'T have IDs*/
1025           miiSrc.fType = MFT_STRING;
1026           miiSrc.dwTypeData = szName;
1027           miiSrc.dwItemData = 0;
1028           miiSrc.cch = sizeof(szName);
1029
1030           if (!GetMenuItemInfo32A(hmSrc, nItem, TRUE, &miiSrc))
1031           { continue;
1032           }
1033           if (miiSrc.fType & MFT_SEPARATOR)
1034           { /* This is a separator; don't put two of them in a row*/
1035             if (bAlreadySeparated)
1036             { continue;
1037             }
1038             bAlreadySeparated = TRUE;
1039           }
1040           else if (miiSrc.hSubMenu)
1041           { if (uFlags & MM_SUBMENUSHAVEIDS)
1042             { /* Adjust the ID and check it*/
1043               miiSrc.wID += uIDAdjust;
1044               if (miiSrc.wID > uIDAdjustMax)
1045               { continue;
1046               }
1047               if (uIDMax <= miiSrc.wID)
1048               { uIDMax = miiSrc.wID + 1;
1049               }
1050             }
1051             else
1052             { /* Don't set IDs for submenus that didn't have them already */
1053               miiSrc.fMask &= ~MIIM_ID;
1054             }
1055             hmSubMenu = miiSrc.hSubMenu;
1056             miiSrc.hSubMenu = CreatePopupMenu32();
1057             if (!miiSrc.hSubMenu)
1058             { return(uIDMax);
1059             }
1060             uTemp = Shell_MergeMenus32(miiSrc.hSubMenu, hmSubMenu, 0, uIDAdjust, uIDAdjustMax, uFlags&MM_SUBMENUSHAVEIDS);
1061             if (uIDMax <= uTemp)
1062             { uIDMax = uTemp;
1063             }
1064             bAlreadySeparated = FALSE;
1065           }
1066           else
1067           { /* Adjust the ID and check it*/
1068             miiSrc.wID += uIDAdjust;
1069             if (miiSrc.wID > uIDAdjustMax)
1070             { continue;
1071             }
1072             if (uIDMax <= miiSrc.wID)
1073             { uIDMax = miiSrc.wID + 1;
1074             }
1075             bAlreadySeparated = FALSE;
1076           }
1077           if (!InsertMenuItem32A(hmDst, uInsert, TRUE, &miiSrc))
1078           { return(uIDMax);
1079           }
1080         }
1081
1082         /* Ensure the correct number of separators at the beginning of the
1083         inserted menu items*/
1084         if (uInsert == 0)
1085         { if (bAlreadySeparated)
1086           { DeleteMenu32(hmDst, uInsert, MF_BYPOSITION);
1087           }
1088         }
1089         else
1090         { if (_SHIsMenuSeparator(hmDst, uInsert-1))
1091           { if (bAlreadySeparated)
1092             { DeleteMenu32(hmDst, uInsert, MF_BYPOSITION);
1093             }
1094           }
1095           else
1096           { if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated)
1097             { /* Add a separator between the menus*/
1098               InsertMenu32A(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
1099             }
1100           }
1101         }
1102         return(uIDMax);
1103
1104 }
1105 /*************************************************************************
1106  * DriveType32 [SHELL32.64]
1107  *
1108  */
1109 HRESULT WINAPI DriveType32(DWORD u)
1110 {       FIXME(shell,"0x%04lx stub\n",u);
1111         return 0;
1112 }
1113 /*************************************************************************
1114  * SHAbortInvokeCommand [SHELL32.198]
1115  *
1116  */
1117 HRESULT WINAPI SHAbortInvokeCommand(void)
1118 {       FIXME(shell,"stub\n");
1119         return 1;
1120 }
1121 /*************************************************************************
1122  * SHOutOfMemoryMessageBox [SHELL32.126]
1123  *
1124  */
1125 HRESULT WINAPI SHOutOfMemoryMessageBox(DWORD u, DWORD v, DWORD w)
1126 {       FIXME(shell,"0x%04lx 0x%04lx 0x%04lx stub\n",u,v,w);
1127         return 0;
1128 }
1129 /*************************************************************************
1130  * SHFlushClipboard [SHELL32.121]
1131  *
1132  */
1133 HRESULT WINAPI SHFlushClipboard(void)
1134 {       FIXME(shell,"stub\n");
1135         return 1;
1136 }
1137 /*************************************************************************
1138  * StrRChrW [SHELL32.320]
1139  *
1140  */
1141 LPWSTR WINAPI StrRChrW(LPWSTR lpStart, LPWSTR lpEnd, DWORD wMatch)
1142 {       LPWSTR wptr=NULL;
1143         TRACE(shell,"%s %s 0x%04x\n",debugstr_w(lpStart),debugstr_w(lpEnd), (WCHAR)wMatch );
1144
1145         /* if the end not given, search*/
1146         if (!lpEnd)
1147         { lpEnd=lpStart;
1148           while (*lpEnd) 
1149             lpEnd++;
1150         }
1151
1152         do 
1153         { if (*lpStart==(WCHAR)wMatch)
1154             wptr = lpStart;
1155           lpStart++;  
1156         } while ( lpStart<=lpEnd ); 
1157         return wptr;
1158 }
1159 /*************************************************************************
1160 *       StrFormatByteSize       [SHLWAPI]
1161 */
1162 LPSTR WINAPI StrFormatByteSize32A ( DWORD dw, LPSTR pszBuf, UINT32 cchBuf )
1163 {       char buf[64];
1164         TRACE(shell,"%lx %p %i\n", dw, pszBuf, cchBuf);
1165         if ( dw<1024L )
1166         { sprintf (buf,"%3.1f bytes", (FLOAT)dw);
1167         }
1168         else if ( dw<1048576L)
1169         { sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
1170         }
1171         else if ( dw < 1073741824L)
1172         { sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
1173         }
1174         else
1175         { sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
1176         }
1177         strncpy (pszBuf, buf, cchBuf);
1178         return pszBuf;  
1179 }
1180 LPWSTR WINAPI StrFormatByteSize32W ( DWORD dw, LPWSTR pszBuf, UINT32 cchBuf )
1181 {       char buf[64];
1182         TRACE(shell,"%lx %p %i\n", dw, pszBuf, cchBuf);
1183         if ( dw<1024L )
1184         { sprintf (buf,"%3.1f bytes", (FLOAT)dw);
1185         }
1186         else if ( dw<1048576L)
1187         { sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
1188         }
1189         else if ( dw < 1073741824L)
1190         { sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
1191         }
1192         else
1193         { sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
1194         }
1195         lstrcpynAtoW (pszBuf, buf, cchBuf);
1196         return pszBuf;  
1197 }
1198 /*************************************************************************
1199  * SHWaitForFileToOpen [SHELL32.97]
1200  *
1201  */
1202 HRESULT WINAPI SHWaitForFileToOpen(DWORD u, DWORD v, DWORD w)
1203 {       FIXME(shell,"0x%04lx 0x%04lx 0x%04lx stub\n",u,v,w);
1204         return 0;
1205 }