Robert Shearman <rob@codeweavers.com>
[reactos.git] / reactos / lib / shell32 / shellord.c
1 /*
2 * The parameters of many functions changes between different OS versions
3 * (NT uses Unicode strings, 95 uses ASCII strings)
4 *
5 * Copyright 1997 Marcus Meissner
6 * 1998 Jürgen Schmied
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 #include "config.h"
23
24 #include <string.h>
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include "winerror.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "wine/debug.h"
32 #include "winnls.h"
33
34 #include "shellapi.h"
35 #include "objbase.h"
36 #include "shlguid.h"
37 #include "wingdi.h"
38 #include "winuser.h"
39 #include "shlobj.h"
40 #include "shell32_main.h"
41 #include "undocshell.h"
42 #include "pidl.h"
43 #include "shlwapi.h"
44 #include "commdlg.h"
45
46 WINE_DEFAULT_DEBUG_CHANNEL(shell);
47 WINE_DECLARE_DEBUG_CHANNEL(pidl);
48
49 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
50 /* !!! it is in both here and comctl32undoc.c !!! */
51 typedef struct tagCREATEMRULIST
52 {
53 DWORD cbSize; /* size of struct */
54 DWORD nMaxItems; /* max no. of items in list */
55 DWORD dwFlags; /* see below */
56 HKEY hKey; /* root reg. key under which list is saved */
57 LPCSTR lpszSubKey; /* reg. subkey */
58 PROC lpfnCompare; /* item compare proc */
59 } CREATEMRULISTA, *LPCREATEMRULISTA;
60
61 /* dwFlags */
62 #define MRUF_STRING_LIST 0 /* list will contain strings */
63 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
64 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
65
66 extern HANDLE WINAPI CreateMRUListA(LPCREATEMRULISTA lpcml);
67 extern DWORD WINAPI FreeMRUList(HANDLE hMRUList);
68 extern INT WINAPI AddMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData);
69 extern INT WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
70 extern INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
71
72
73 /* Get a function pointer from a DLL handle */
74 #define GET_FUNC(func, module, name, fail) \
75 do { \
76 if (!func) { \
77 if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
78 func = (void*)GetProcAddress(SHELL32_h##module, name); \
79 if (!func) return fail; \
80 } \
81 } while (0)
82
83 /* Function pointers for GET_FUNC macro */
84 static HMODULE SHELL32_hshlwapi=NULL;
85 static HANDLE (WINAPI *pSHAllocShared)(LPCVOID,DWORD,DWORD);
86 static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD);
87 static BOOL (WINAPI *pSHUnlockShared)(LPVOID);
88 static BOOL (WINAPI *pSHFreeShared)(HANDLE,DWORD);
89
90
91 /*************************************************************************
92 * ParseFieldA [internal]
93 *
94 * copies a field from a ',' delimited string
95 *
96 * first field is nField = 1
97 */
98 DWORD WINAPI ParseFieldA(
99 LPCSTR src,
100 DWORD nField,
101 LPSTR dst,
102 DWORD len)
103 {
104 WARN("(%s,0x%08lx,%p,%ld) semi-stub.\n",debugstr_a(src),nField,dst,len);
105
106 if (!src || !src[0] || !dst || !len)
107 return 0;
108
109 /* skip n fields delimited by ',' */
110 while (nField > 1)
111 {
112 if (*src=='\0') return FALSE;
113 if (*(src++)==',') nField--;
114 }
115
116 /* copy part till the next ',' to dst */
117 while ( *src!='\0' && *src!=',' && (len--)>0 ) *(dst++)=*(src++);
118
119 /* finalize the string */
120 *dst=0x0;
121
122 return TRUE;
123 }
124
125 /*************************************************************************
126 * ParseFieldW [internal]
127 *
128 * copies a field from a ',' delimited string
129 *
130 * first field is nField = 1
131 */
132 DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len)
133 {
134 WARN("(%s,0x%08lx,%p,%ld) semi-stub.\n", debugstr_w(src), nField, dst, len);
135
136 if (!src || !src[0] || !dst || !len)
137 return 0;
138
139 /* skip n fields delimited by ',' */
140 while (nField > 1)
141 {
142 if (*src == 0x0) return FALSE;
143 if (*src++ == ',') nField--;
144 }
145
146 /* copy part till the next ',' to dst */
147 while ( *src != 0x0 && *src != ',' && (len--)>0 ) *(dst++) = *(src++);
148
149 /* finalize the string */
150 *dst = 0x0;
151
152 return TRUE;
153 }
154
155 /*************************************************************************
156 * ParseField [SHELL32.58]
157 */
158 DWORD WINAPI ParseFieldAW(LPCVOID src, DWORD nField, LPVOID dst, DWORD len)
159 {
160 if (SHELL_OsIsUnicode())
161 return ParseFieldW(src, nField, dst, len);
162 return ParseFieldA(src, nField, dst, len);
163 }
164
165 /*************************************************************************
166 * GetFileNameFromBrowse [SHELL32.63]
167 *
168 */
169 BOOL WINAPI GetFileNameFromBrowse(
170 HWND hwndOwner,
171 LPSTR lpstrFile,
172 DWORD nMaxFile,
173 LPCSTR lpstrInitialDir,
174 LPCSTR lpstrDefExt,
175 LPCSTR lpstrFilter,
176 LPCSTR lpstrTitle)
177 {
178 HMODULE hmodule;
179 FARPROC pGetOpenFileNameA;
180 OPENFILENAMEA ofn;
181 BOOL ret;
182
183 TRACE("%p, %s, %ld, %s, %s, %s, %s)\n",
184 hwndOwner, lpstrFile, nMaxFile, lpstrInitialDir, lpstrDefExt,
185 lpstrFilter, lpstrTitle);
186
187 hmodule = LoadLibraryA("comdlg32.dll");
188 if(!hmodule) return FALSE;
189 pGetOpenFileNameA = GetProcAddress(hmodule, "GetOpenFileNameA");
190 if(!pGetOpenFileNameA)
191 {
192 FreeLibrary(hmodule);
193 return FALSE;
194 }
195
196 memset(&ofn, 0, sizeof(ofn));
197
198 ofn.lStructSize = sizeof(ofn);
199 ofn.hwndOwner = hwndOwner;
200 ofn.lpstrFilter = lpstrFilter;
201 ofn.lpstrFile = lpstrFile;
202 ofn.nMaxFile = nMaxFile;
203 ofn.lpstrInitialDir = lpstrInitialDir;
204 ofn.lpstrTitle = lpstrTitle;
205 ofn.lpstrDefExt = lpstrDefExt;
206 ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
207 ret = pGetOpenFileNameA(&ofn);
208
209 FreeLibrary(hmodule);
210 return ret;
211 }
212
213 /*************************************************************************
214 * SHGetSetSettings [SHELL32.68]
215 */
216 VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
217 {
218 if(bSet)
219 {
220 FIXME("%p 0x%08lx TRUE\n", lpss, dwMask);
221 }
222 else
223 {
224 SHGetSettings((LPSHELLFLAGSTATE)lpss,dwMask);
225 }
226 }
227
228 /*************************************************************************
229 * SHGetSettings [SHELL32.@]
230 *
231 * NOTES
232 * the registry path are for win98 (tested)
233 * and possibly are the same in nt40
234 *
235 * FIXME: implement new flags such as SSF_WIN95CLASSIC and SSF_STARTPANELON
236 *
237 */
238 VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask)
239 {
240 HKEY hKey;
241 DWORD dwData;
242 DWORD dwDataSize = sizeof (DWORD);
243
244 TRACE("(%p 0x%08lx)\n",lpsfs,dwMask);
245
246 if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
247 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0))
248 return;
249
250 if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize))
251 lpsfs->fShowExtensions = ((dwData == 0) ? 0 : 1);
252
253 if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize))
254 lpsfs->fShowInfoTip = ((dwData == 0) ? 0 : 1);
255
256 if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize))
257 lpsfs->fDontPrettyPath = ((dwData == 0) ? 0 : 1);
258
259 if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize))
260 lpsfs->fHideIcons = ((dwData == 0) ? 0 : 1);
261
262 if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize))
263 lpsfs->fMapNetDrvBtn = ((dwData == 0) ? 0 : 1);
264
265 if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize))
266 lpsfs->fShowAttribCol = ((dwData == 0) ? 0 : 1);
267
268 if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize))
269 { if (dwData == 0)
270 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
271 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
272 }
273 else if (dwData == 1)
274 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 1;
275 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
276 }
277 else if (dwData == 2)
278 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
279 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 1;
280 }
281 }
282 RegCloseKey (hKey);
283
284 TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
285 }
286
287 /*************************************************************************
288 * SHShellFolderView_Message [SHELL32.73]
289 *
290 * Send a message to an explorer cabinet window.
291 *
292 * PARAMS
293 * hwndCabinet [I] The window containing the shellview to communicate with
294 * dwMessage [I] The SFVM message to send
295 * dwParam [I] Message parameter
296 *
297 * RETURNS
298 * fixme.
299 *
300 * NOTES
301 * Message SFVM_REARRANGE = 1
302 *
303 * This message gets sent when a column gets clicked to instruct the
304 * shell view to re-sort the item list. dwParam identifies the column
305 * that was clicked.
306 */
307 LRESULT WINAPI SHShellFolderView_Message(
308 HWND hwndCabinet,
309 UINT uMessage,
310 LPARAM lParam)
311 {
312 FIXME("%p %08x %08lx stub\n",hwndCabinet, uMessage, lParam);
313 return 0;
314 }
315
316 /*************************************************************************
317 * RegisterShellHook [SHELL32.181]
318 *
319 * Register a shell hook.
320 *
321 * PARAMS
322 * hwnd [I] Window handle
323 * dwType [I] Type of hook.
324 *
325 * NOTES
326 * Exported by ordinal
327 */
328 BOOL WINAPI RegisterShellHook(
329 HWND hWnd,
330 DWORD dwType)
331 {
332 FIXME("(%p,0x%08lx):stub.\n",hWnd, dwType);
333 return TRUE;
334 }
335
336 /*************************************************************************
337 * ShellMessageBoxW [SHELL32.182]
338 *
339 * See ShellMessageBoxA.
340 */
341 int WINAPIV ShellMessageBoxW(
342 HINSTANCE hInstance,
343 HWND hWnd,
344 LPCWSTR lpText,
345 LPCWSTR lpCaption,
346 UINT uType,
347 ...)
348 {
349 WCHAR szText[100],szTitle[100];
350 LPCWSTR pszText = szText, pszTitle = szTitle, pszTemp;
351 va_list args;
352 int ret;
353
354 va_start(args, uType);
355 /* wvsprintfA(buf,fmt, args); */
356
357 TRACE("(%08lx,%08lx,%p,%p,%08x)\n",
358 (DWORD)hInstance,(DWORD)hWnd,lpText,lpCaption,uType);
359
360 if (!HIWORD(lpCaption))
361 LoadStringW(hInstance, (DWORD)lpCaption, szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
362 else
363 pszTitle = lpCaption;
364
365 if (!HIWORD(lpText))
366 LoadStringW(hInstance, (DWORD)lpText, szText, sizeof(szText)/sizeof(szText[0]));
367 else
368 pszText = lpText;
369
370 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
371 pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
372
373 va_end(args);
374
375 ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
376 LocalFree((HLOCAL)pszTemp);
377 return ret;
378 }
379
380 /*************************************************************************
381 * ShellMessageBoxA [SHELL32.183]
382 *
383 * Format and output an error message.
384 *
385 * PARAMS
386 * hInstance [I] Instance handle of message creator
387 * hWnd [I] Window handle of message creator
388 * lpText [I] Resource Id of title or LPSTR
389 * lpCaption [I] Resource Id of title or LPSTR
390 * uType [I] Type of error message
391 *
392 * RETURNS
393 * A return value from MessageBoxA().
394 *
395 * NOTES
396 * Exported by ordinal
397 */
398 int WINAPIV ShellMessageBoxA(
399 HINSTANCE hInstance,
400 HWND hWnd,
401 LPCSTR lpText,
402 LPCSTR lpCaption,
403 UINT uType,
404 ...)
405 {
406 char szText[100],szTitle[100];
407 LPCSTR pszText = szText, pszTitle = szTitle, pszTemp;
408 va_list args;
409 int ret;
410
411 va_start(args, uType);
412 /* wvsprintfA(buf,fmt, args); */
413
414 TRACE("(%08lx,%08lx,%p,%p,%08x)\n",
415 (DWORD)hInstance,(DWORD)hWnd,lpText,lpCaption,uType);
416
417 if (!HIWORD(lpCaption))
418 LoadStringA(hInstance, (DWORD)lpCaption, szTitle, sizeof(szTitle));
419 else
420 pszTitle = lpCaption;
421
422 if (!HIWORD(lpText))
423 LoadStringA(hInstance, (DWORD)lpText, szText, sizeof(szText));
424 else
425 pszText = lpText;
426
427 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
428 pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
429
430 va_end(args);
431
432 ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
433 LocalFree((HLOCAL)pszTemp);
434 return ret;
435 }
436
437 /*************************************************************************
438 * SHRegisterDragDrop [SHELL32.86]
439 *
440 * NOTES
441 * exported by ordinal
442 */
443 HRESULT WINAPI SHRegisterDragDrop(
444 HWND hWnd,
445 LPDROPTARGET pDropTarget)
446 {
447 FIXME("(%p,%p):stub.\n", hWnd, pDropTarget);
448 return RegisterDragDrop(hWnd, pDropTarget);
449 }
450
451 /*************************************************************************
452 * SHRevokeDragDrop [SHELL32.87]
453 *
454 * NOTES
455 * exported by ordinal
456 */
457 HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
458 {
459 FIXME("(%p):stub.\n",hWnd);
460 return RevokeDragDrop(hWnd);
461 }
462
463 /*************************************************************************
464 * SHDoDragDrop [SHELL32.88]
465 *
466 * NOTES
467 * exported by ordinal
468 */
469 HRESULT WINAPI SHDoDragDrop(
470 HWND hWnd,
471 LPDATAOBJECT lpDataObject,
472 LPDROPSOURCE lpDropSource,
473 DWORD dwOKEffect,
474 LPDWORD pdwEffect)
475 {
476 FIXME("(%p %p %p 0x%08lx %p):stub.\n",
477 hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
478 return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
479 }
480
481 /*************************************************************************
482 * ArrangeWindows [SHELL32.184]
483 *
484 */
485 WORD WINAPI ArrangeWindows(
486 HWND hwndParent,
487 DWORD dwReserved,
488 LPCRECT lpRect,
489 WORD cKids,
490 CONST HWND * lpKids)
491 {
492 FIXME("(%p 0x%08lx %p 0x%04x %p):stub.\n",
493 hwndParent, dwReserved, lpRect, cKids, lpKids);
494 return 0;
495 }
496
497 /*************************************************************************
498 * SignalFileOpen [SHELL32.103]
499 *
500 * NOTES
501 * exported by ordinal
502 */
503 DWORD WINAPI
504 SignalFileOpen (DWORD dwParam1)
505 {
506 FIXME("(0x%08lx):stub.\n", dwParam1);
507
508 return 0;
509 }
510
511 /*************************************************************************
512 * SHADD_get_policy - helper function for SHAddToRecentDocs
513 *
514 * PARAMETERS
515 * policy [IN] policy name (null termed string) to find
516 * type [OUT] ptr to DWORD to receive type
517 * buffer [OUT] ptr to area to hold data retrieved
518 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
519 * length filled
520 *
521 * RETURNS
522 * result of the SHQueryValueEx call
523 */
524 static INT SHADD_get_policy(LPSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
525 {
526 HKEY Policy_basekey;
527 INT ret;
528
529 /* Get the key for the policies location in the registry
530 */
531 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
532 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
533 0, KEY_READ, &Policy_basekey)) {
534
535 if (RegOpenKeyExA(HKEY_CURRENT_USER,
536 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
537 0, KEY_READ, &Policy_basekey)) {
538 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
539 policy);
540 *len = 0;
541 return ERROR_FILE_NOT_FOUND;
542 }
543 }
544
545 /* Retrieve the data if it exists
546 */
547 ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len);
548 RegCloseKey(Policy_basekey);
549 return ret;
550 }
551
552
553 /*************************************************************************
554 * SHADD_compare_mru - helper function for SHAddToRecentDocs
555 *
556 * PARAMETERS
557 * data1 [IN] data being looked for
558 * data2 [IN] data in MRU
559 * cbdata [IN] length from FindMRUData call (not used)
560 *
561 * RETURNS
562 * position within MRU list that data was added.
563 */
564 static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData)
565 {
566 return lstrcmpiA(data1, data2);
567 }
568
569 /*************************************************************************
570 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
571 *
572 * PARAMETERS
573 * mruhandle [IN] handle for created MRU list
574 * doc_name [IN] null termed pure doc name
575 * new_lnk_name [IN] null termed path and file name for .lnk file
576 * buffer [IN/OUT] 2048 byte area to consturct MRU data
577 * len [OUT] ptr to int to receive space used in buffer
578 *
579 * RETURNS
580 * position within MRU list that data was added.
581 */
582 static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPSTR doc_name, LPSTR new_lnk_name,
583 LPSTR buffer, INT *len)
584 {
585 LPSTR ptr;
586 INT wlen;
587
588 /*FIXME: Document:
589 * RecentDocs MRU data structure seems to be:
590 * +0h document file name w/ terminating 0h
591 * +nh short int w/ size of remaining
592 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
593 * +n+4h 10 bytes zeros - unknown
594 * +n+eh shortcut file name w/ terminating 0h
595 * +n+e+nh 3 zero bytes - unknown
596 */
597
598 /* Create the MRU data structure for "RecentDocs"
599 */
600 ptr = buffer;
601 lstrcpyA(ptr, doc_name);
602 ptr += (lstrlenA(buffer) + 1);
603 wlen= lstrlenA(new_lnk_name) + 1 + 12;
604 *((short int*)ptr) = wlen;
605 ptr += 2; /* step past the length */
606 *(ptr++) = 0x30; /* unknown reason */
607 *(ptr++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
608 memset(ptr, 0, 10);
609 ptr += 10;
610 lstrcpyA(ptr, new_lnk_name);
611 ptr += (lstrlenA(new_lnk_name) + 1);
612 memset(ptr, 0, 3);
613 ptr += 3;
614 *len = ptr - buffer;
615
616 /* Add the new entry into the MRU list
617 */
618 return AddMRUData(mruhandle, (LPCVOID)buffer, *len);
619 }
620
621 /*************************************************************************
622 * SHAddToRecentDocs [SHELL32.@]
623 *
624 * PARAMETERS
625 * uFlags [IN] SHARD_PATH or SHARD_PIDL
626 * pv [IN] string or pidl, NULL clears the list
627 *
628 * NOTES
629 * exported by name
630 *
631 */
632 void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
633 {
634 /* If list is a string list lpfnCompare has the following prototype
635 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
636 * for binary lists the prototype is
637 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
638 * where cbData is the no. of bytes to compare.
639 * Need to check what return value means identical - 0?
640 */
641
642
643 UINT olderrormode;
644 HKEY HCUbasekey;
645 CHAR doc_name[MAX_PATH];
646 CHAR link_dir[MAX_PATH];
647 CHAR new_lnk_filepath[MAX_PATH];
648 CHAR new_lnk_name[MAX_PATH];
649 IMalloc *ppM;
650 LPITEMIDLIST pidl;
651 HWND hwnd = 0; /* FIXME: get real window handle */
652 INT ret;
653 DWORD data[64], datalen, type;
654
655 /*FIXME: Document:
656 * RecentDocs MRU data structure seems to be:
657 * +0h document file name w/ terminating 0h
658 * +nh short int w/ size of remaining
659 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
660 * +n+4h 10 bytes zeros - unknown
661 * +n+eh shortcut file name w/ terminating 0h
662 * +n+e+nh 3 zero bytes - unknown
663 */
664
665 /* See if we need to do anything.
666 */
667 datalen = 64;
668 ret=SHADD_get_policy( "NoRecentDocsHistory", &type, &data, &datalen);
669 if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) {
670 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret);
671 return;
672 }
673 if (ret == ERROR_SUCCESS) {
674 if (!( (type == REG_DWORD) ||
675 ((type == REG_BINARY) && (datalen == 4)) )) {
676 ERR("Error policy data for \"NoRecentDocsHistory\" not formated correctly, type=%ld, len=%ld\n",
677 type, datalen);
678 return;
679 }
680
681 TRACE("policy value for NoRecentDocsHistory = %08lx\n", data[0]);
682 /* now test the actual policy value */
683 if ( data[0] != 0)
684 return;
685 }
686
687 /* Open key to where the necessary info is
688 */
689 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
690 * and the close should be done during the _DETACH. The resulting
691 * key is stored in the DLL global data.
692 */
693 if (RegCreateKeyExA(HKEY_CURRENT_USER,
694 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
695 0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
696 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
697 return;
698 }
699
700 /* Get path to user's "Recent" directory
701 */
702 if(SUCCEEDED(SHGetMalloc(&ppM))) {
703 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
704 &pidl))) {
705 SHGetPathFromIDListA(pidl, link_dir);
706 IMalloc_Free(ppM, pidl);
707 }
708 else {
709 /* serious issues */
710 link_dir[0] = 0;
711 ERR("serious issues 1\n");
712 }
713 IMalloc_Release(ppM);
714 }
715 else {
716 /* serious issues */
717 link_dir[0] = 0;
718 ERR("serious issues 2\n");
719 }
720 TRACE("Users Recent dir %s\n", link_dir);
721
722 /* If no input, then go clear the lists */
723 if (!pv) {
724 /* clear user's Recent dir
725 */
726
727 /* FIXME: delete all files in "link_dir"
728 *
729 * while( more files ) {
730 * lstrcpyA(old_lnk_name, link_dir);
731 * PathAppendA(old_lnk_name, filenam);
732 * DeleteFileA(old_lnk_name);
733 * }
734 */
735 FIXME("should delete all files in %s\\ \n", link_dir);
736
737 /* clear MRU list
738 */
739 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
740 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
741 * and naturally it fails w/ rc=2. It should do it against
742 * HKEY_CURRENT_USER which is where it is stored, and where
743 * the MRU routines expect it!!!!
744 */
745 RegDeleteKeyA(HCUbasekey, "RecentDocs");
746 RegCloseKey(HCUbasekey);
747 return;
748 }
749
750 /* Have data to add, the jobs to be done:
751 * 1. Add document to MRU list in registry "HKCU\Software\
752 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
753 * 2. Add shortcut to document in the user's Recent directory
754 * (CSIDL_RECENT).
755 * 3. Add shortcut to Start menu's Documents submenu.
756 */
757
758 /* Get the pure document name from the input
759 */
760 if (uFlags & SHARD_PIDL) {
761 SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name);
762 }
763 else {
764 lstrcpyA(doc_name, (LPSTR) pv);
765 }
766 TRACE("full document name %s\n", doc_name);
767 PathStripPathA(doc_name);
768 TRACE("stripped document name %s\n", doc_name);
769
770
771 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
772
773 { /* on input needs:
774 * doc_name - pure file-spec, no path
775 * link_dir - path to the user's Recent directory
776 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
777 * creates:
778 * new_lnk_name- pure file-spec, no path for new .lnk file
779 * new_lnk_filepath
780 * - path and file name of new .lnk file
781 */
782 CREATEMRULISTA mymru;
783 HANDLE mruhandle;
784 INT len, pos, bufused, err;
785 INT i;
786 DWORD attr;
787 CHAR buffer[2048];
788 CHAR *ptr;
789 CHAR old_lnk_name[MAX_PATH];
790 short int slen;
791
792 mymru.cbSize = sizeof(CREATEMRULISTA);
793 mymru.nMaxItems = 15;
794 mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE;
795 mymru.hKey = HCUbasekey;
796 mymru.lpszSubKey = "RecentDocs";
797 mymru.lpfnCompare = &SHADD_compare_mru;
798 mruhandle = CreateMRUListA(&mymru);
799 if (!mruhandle) {
800 /* MRU failed */
801 ERR("MRU processing failed, handle zero\n");
802 RegCloseKey(HCUbasekey);
803 return;
804 }
805 len = lstrlenA(doc_name);
806 pos = FindMRUData(mruhandle, doc_name, len, 0);
807
808 /* Now get the MRU entry that will be replaced
809 * and delete the .lnk file for it
810 */
811 if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos,
812 buffer, 2048)) != -1) {
813 ptr = buffer;
814 ptr += (lstrlenA(buffer) + 1);
815 slen = *((short int*)ptr);
816 ptr += 2; /* skip the length area */
817 if (bufused >= slen + (ptr-buffer)) {
818 /* buffer size looks good */
819 ptr += 12; /* get to string */
820 len = bufused - (ptr-buffer); /* get length of buf remaining */
821 if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
822 /* appears to be good string */
823 lstrcpyA(old_lnk_name, link_dir);
824 PathAppendA(old_lnk_name, ptr);
825 if (!DeleteFileA(old_lnk_name)) {
826 if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
827 if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
828 ERR("Delete for %s failed, err=%d, attr=%08lx\n",
829 old_lnk_name, err, attr);
830 }
831 else {
832 TRACE("old .lnk file %s did not exist\n",
833 old_lnk_name);
834 }
835 }
836 else {
837 ERR("Delete for %s failed, attr=%08lx\n",
838 old_lnk_name, attr);
839 }
840 }
841 else {
842 TRACE("deleted old .lnk file %s\n", old_lnk_name);
843 }
844 }
845 }
846 }
847
848 /* Create usable .lnk file name for the "Recent" directory
849 */
850 wsprintfA(new_lnk_name, "%s.lnk", doc_name);
851 lstrcpyA(new_lnk_filepath, link_dir);
852 PathAppendA(new_lnk_filepath, new_lnk_name);
853 i = 1;
854 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
855 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
856 i++;
857 wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
858 lstrcpyA(new_lnk_filepath, link_dir);
859 PathAppendA(new_lnk_filepath, new_lnk_name);
860 }
861 SetErrorMode(olderrormode);
862 TRACE("new shortcut will be %s\n", new_lnk_filepath);
863
864 /* Now add the new MRU entry and data
865 */
866 pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name,
867 buffer, &len);
868 FreeMRUList(mruhandle);
869 TRACE("Updated MRU list, new doc is position %d\n", pos);
870 }
871
872 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
873
874 { /* on input needs:
875 * doc_name - pure file-spec, no path
876 * new_lnk_filepath
877 * - path and file name of new .lnk file
878 * uFlags[in] - flags on call to SHAddToRecentDocs
879 * pv[in] - document path/pidl on call to SHAddToRecentDocs
880 */
881 IShellLinkA *psl = NULL;
882 IPersistFile *pPf = NULL;
883 HRESULT hres;
884 CHAR desc[MAX_PATH];
885 WCHAR widelink[MAX_PATH];
886
887 CoInitialize(0);
888
889 hres = CoCreateInstance( &CLSID_ShellLink,
890 NULL,
891 CLSCTX_INPROC_SERVER,
892 &IID_IShellLinkA,
893 (LPVOID )&psl);
894 if(SUCCEEDED(hres)) {
895
896 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
897 (LPVOID *)&pPf);
898 if(FAILED(hres)) {
899 /* bombed */
900 ERR("failed QueryInterface for IPersistFile %08lx\n", hres);
901 goto fail;
902 }
903
904 /* Set the document path or pidl */
905 if (uFlags & SHARD_PIDL) {
906 hres = IShellLinkA_SetIDList(psl, (LPCITEMIDLIST) pv);
907 } else {
908 hres = IShellLinkA_SetPath(psl, (LPCSTR) pv);
909 }
910 if(FAILED(hres)) {
911 /* bombed */
912 ERR("failed Set{IDList|Path} %08lx\n", hres);
913 goto fail;
914 }
915
916 lstrcpyA(desc, "Shortcut to ");
917 lstrcatA(desc, doc_name);
918 hres = IShellLinkA_SetDescription(psl, desc);
919 if(FAILED(hres)) {
920 /* bombed */
921 ERR("failed SetDescription %08lx\n", hres);
922 goto fail;
923 }
924
925 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
926 widelink, MAX_PATH);
927 /* create the short cut */
928 hres = IPersistFile_Save(pPf, widelink, TRUE);
929 if(FAILED(hres)) {
930 /* bombed */
931 ERR("failed IPersistFile::Save %08lx\n", hres);
932 IPersistFile_Release(pPf);
933 IShellLinkA_Release(psl);
934 goto fail;
935 }
936 hres = IPersistFile_SaveCompleted(pPf, widelink);
937 IPersistFile_Release(pPf);
938 IShellLinkA_Release(psl);
939 TRACE("shortcut %s has been created, result=%08lx\n",
940 new_lnk_filepath, hres);
941 }
942 else {
943 ERR("CoCreateInstance failed, hres=%08lx\n", hres);
944 }
945 }
946
947 fail:
948 CoUninitialize();
949
950 /* all done */
951 RegCloseKey(HCUbasekey);
952 return;
953 }
954
955 /*************************************************************************
956 * SHCreateShellFolderViewEx [SHELL32.174]
957 *
958 * NOTES
959 * see IShellFolder::CreateViewObject
960 */
961 HRESULT WINAPI SHCreateShellFolderViewEx(
962 LPCSFV psvcbi, /* [in] shelltemplate struct */
963 IShellView **ppv) /* [out] IShellView pointer */
964 {
965 IShellView * psf;
966 HRESULT hRes;
967
968 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
969 psvcbi->pshf, psvcbi->pidlFolder, psvcbi->pfnCallback,
970 psvcbi->fvm, psvcbi->psvOuter);
971
972 psf = IShellView_Constructor(psvcbi->pshf);
973
974 if (!psf)
975 return E_OUTOFMEMORY;
976
977 IShellView_AddRef(psf);
978 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
979 IShellView_Release(psf);
980
981 return hRes;
982 }
983 /*************************************************************************
984 * SHWinHelp [SHELL32.127]
985 *
986 */
987 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
988 { FIXME("0x%08lx 0x%08lx 0x%08lx 0x%08lx stub\n",v,w,x,z);
989 return 0;
990 }
991 /*************************************************************************
992 * SHRunControlPanel [SHELL32.161]
993 *
994 */
995 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
996 { FIXME("0x%08lx 0x%08lx stub\n",x,z);
997 return 0;
998 }
999
1000 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1001 /*************************************************************************
1002 * SHSetInstanceExplorer [SHELL32.176]
1003 *
1004 * NOTES
1005 * Sets the interface
1006 */
1007 HRESULT WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1008 { TRACE("%p\n", lpUnknown);
1009 SHELL32_IExplorerInterface = lpUnknown;
1010 return (HRESULT) lpUnknown;
1011 }
1012 /*************************************************************************
1013 * SHGetInstanceExplorer [SHELL32.@]
1014 *
1015 * NOTES
1016 * gets the interface pointer of the explorer and a reference
1017 */
1018 HRESULT WINAPI SHGetInstanceExplorer (LPUNKNOWN * lpUnknown)
1019 { TRACE("%p\n", lpUnknown);
1020
1021 *lpUnknown = SHELL32_IExplorerInterface;
1022
1023 if (!SHELL32_IExplorerInterface)
1024 return E_FAIL;
1025
1026 IUnknown_AddRef(SHELL32_IExplorerInterface);
1027 return NOERROR;
1028 }
1029 /*************************************************************************
1030 * SHFreeUnusedLibraries [SHELL32.123]
1031 *
1032 * NOTES
1033 * exported by name
1034 */
1035 void WINAPI SHFreeUnusedLibraries (void)
1036 {
1037 FIXME("stub\n");
1038 }
1039 /*************************************************************************
1040 * DAD_AutoScroll [SHELL32.129]
1041 *
1042 */
1043 BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, LPPOINT pt)
1044 {
1045 FIXME("hwnd = %p %p %p\n",hwnd,samples,pt);
1046 return 0;
1047 }
1048 /*************************************************************************
1049 * DAD_DragEnter [SHELL32.130]
1050 *
1051 */
1052 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1053 {
1054 FIXME("hwnd = %p\n",hwnd);
1055 return FALSE;
1056 }
1057 /*************************************************************************
1058 * DAD_DragEnterEx [SHELL32.131]
1059 *
1060 */
1061 BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p)
1062 {
1063 FIXME("hwnd = %p (%ld,%ld)\n",hwnd,p.x,p.y);
1064 return FALSE;
1065 }
1066 /*************************************************************************
1067 * DAD_DragMove [SHELL32.134]
1068 *
1069 */
1070 BOOL WINAPI DAD_DragMove(POINT p)
1071 {
1072 FIXME("(%ld,%ld)\n",p.x,p.y);
1073 return FALSE;
1074 }
1075 /*************************************************************************
1076 * DAD_DragLeave [SHELL32.132]
1077 *
1078 */
1079 BOOL WINAPI DAD_DragLeave(VOID)
1080 {
1081 FIXME("\n");
1082 return FALSE;
1083 }
1084 /*************************************************************************
1085 * DAD_SetDragImage [SHELL32.136]
1086 *
1087 * NOTES
1088 * exported by name
1089 */
1090 BOOL WINAPI DAD_SetDragImage(
1091 HIMAGELIST himlTrack,
1092 LPPOINT lppt)
1093 {
1094 FIXME("%p %p stub\n",himlTrack, lppt);
1095 return 0;
1096 }
1097 /*************************************************************************
1098 * DAD_ShowDragImage [SHELL32.137]
1099 *
1100 * NOTES
1101 * exported by name
1102 */
1103 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1104 {
1105 FIXME("0x%08x stub\n",bShow);
1106 return 0;
1107 }
1108
1109 static const WCHAR szwCabLocation[] = {
1110 'S','o','f','t','w','a','r','e','\\',
1111 'M','i','c','r','o','s','o','f','t','\\',
1112 'W','i','n','d','o','w','s','\\',
1113 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1114 'E','x','p','l','o','r','e','r','\\',
1115 'C','a','b','i','n','e','t','S','t','a','t','e',0
1116 };
1117
1118 static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 };
1119
1120 /*************************************************************************
1121 * ReadCabinetState [SHELL32.651] NT 4.0
1122 *
1123 */
1124 BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
1125 {
1126 HKEY hkey = 0;
1127 DWORD type, r;
1128
1129 TRACE("%p %d \n",cs,length);
1130
1131 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1132 return FALSE;
1133
1134 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1135 if( r == ERROR_SUCCESS )
1136 {
1137 type = REG_BINARY;
1138 r = RegQueryValueExW( hkey, szwSettings,
1139 NULL, &type, (LPBYTE)cs, (LPDWORD)&length );
1140 RegCloseKey( hkey );
1141
1142 }
1143
1144 /* if we can't read from the registry, create default values */
1145 if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) ||
1146 (cs->cLength != length) )
1147 {
1148 ERR("Initializing shell cabinet settings\n");
1149 memset(cs, 0, sizeof(*cs));
1150 cs->cLength = sizeof(*cs);
1151 cs->nVersion = 2;
1152 cs->fFullPathTitle = FALSE;
1153 cs->fSaveLocalView = TRUE;
1154 cs->fNotShell = FALSE;
1155 cs->fSimpleDefault = TRUE;
1156 cs->fDontShowDescBar = FALSE;
1157 cs->fNewWindowMode = FALSE;
1158 cs->fShowCompColor = FALSE;
1159 cs->fDontPrettyNames = FALSE;
1160 cs->fAdminsCreateCommonGroups = TRUE;
1161 cs->fMenuEnumFilter = 96;
1162 }
1163
1164 return TRUE;
1165 }
1166
1167 /*************************************************************************
1168 * WriteCabinetState [SHELL32.652] NT 4.0
1169 *
1170 */
1171 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1172 {
1173 DWORD r;
1174 HKEY hkey = 0;
1175
1176 TRACE("%p\n",cs);
1177
1178 if( cs == NULL )
1179 return FALSE;
1180
1181 r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0,
1182 NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
1183 if( r == ERROR_SUCCESS )
1184 {
1185 r = RegSetValueExW( hkey, szwSettings, 0,
1186 REG_BINARY, (LPBYTE) cs, cs->cLength);
1187
1188 RegCloseKey( hkey );
1189 }
1190
1191 return (r==ERROR_SUCCESS);
1192 }
1193
1194 /*************************************************************************
1195 * FileIconInit [SHELL32.660]
1196 *
1197 */
1198 BOOL WINAPI FileIconInit(BOOL bFullInit)
1199 { FIXME("(%s)\n", bFullInit ? "true" : "false");
1200 return 0;
1201 }
1202 /*************************************************************************
1203 * IsUserAdmin [SHELL32.680] NT 4.0
1204 *
1205 */
1206 HRESULT WINAPI IsUserAdmin(void)
1207 { FIXME("stub\n");
1208 return TRUE;
1209 }
1210
1211 /*************************************************************************
1212 * SHAllocShared [SHELL32.520]
1213 *
1214 * See shlwapi.SHAllocShared
1215 */
1216 HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
1217 {
1218 GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
1219 return pSHAllocShared(lpvData, dwSize, dwProcId);
1220 }
1221
1222 /*************************************************************************
1223 * SHLockShared [SHELL32.521]
1224 *
1225 * See shlwapi.SHLockShared
1226 */
1227 LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
1228 {
1229 GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
1230 return pSHLockShared(hShared, dwProcId);
1231 }
1232
1233 /*************************************************************************
1234 * SHUnlockShared [SHELL32.522]
1235 *
1236 * See shlwapi.SHUnlockShared
1237 */
1238 BOOL WINAPI SHUnlockShared(LPVOID lpView)
1239 {
1240 GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
1241 return pSHUnlockShared(lpView);
1242 }
1243
1244 /*************************************************************************
1245 * SHFreeShared [SHELL32.523]
1246 *
1247 * See shlwapi.SHFreeShared
1248 */
1249 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
1250 {
1251 GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
1252 return pSHFreeShared(hShared, dwProcId);
1253 }
1254
1255 /*************************************************************************
1256 * SetAppStartingCursor [SHELL32.99]
1257 */
1258 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1259 { FIXME("hwnd=%p 0x%04lx stub\n",u,v );
1260 return 0;
1261 }
1262 /*************************************************************************
1263 * SHLoadOLE [SHELL32.151]
1264 *
1265 */
1266 HRESULT WINAPI SHLoadOLE(LPARAM lParam)
1267 { FIXME("0x%04lx stub\n",lParam);
1268 return S_OK;
1269 }
1270 /*************************************************************************
1271 * DriveType [SHELL32.64]
1272 *
1273 */
1274 HRESULT WINAPI DriveType(DWORD u)
1275 { FIXME("0x%04lx stub\n",u);
1276 return 0;
1277 }
1278 /*************************************************************************
1279 * SHAbortInvokeCommand [SHELL32.198]
1280 *
1281 */
1282 HRESULT WINAPI SHAbortInvokeCommand(void)
1283 { FIXME("stub\n");
1284 return 1;
1285 }
1286 /*************************************************************************
1287 * SHOutOfMemoryMessageBox [SHELL32.126]
1288 *
1289 */
1290 int WINAPI SHOutOfMemoryMessageBox(
1291 HWND hwndOwner,
1292 LPCSTR lpCaption,
1293 UINT uType)
1294 {
1295 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1296 return 0;
1297 }
1298 /*************************************************************************
1299 * SHFlushClipboard [SHELL32.121]
1300 *
1301 */
1302 HRESULT WINAPI SHFlushClipboard(void)
1303 { FIXME("stub\n");
1304 return 1;
1305 }
1306
1307 /*************************************************************************
1308 * SHWaitForFileToOpen [SHELL32.97]
1309 *
1310 */
1311 BOOL WINAPI SHWaitForFileToOpen(
1312 LPCITEMIDLIST pidl,
1313 DWORD dwFlags,
1314 DWORD dwTimeout)
1315 {
1316 FIXME("%p 0x%08lx 0x%08lx stub\n", pidl, dwFlags, dwTimeout);
1317 return 0;
1318 }
1319
1320 /************************************************************************
1321 * @ [SHELL32.654]
1322 *
1323 * NOTES: first parameter seems to be a pointer (same as passed to WriteCabinetState)
1324 * second one could be a size (0x0c). The size is the same as the structure saved to
1325 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1326 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1327 */
1328 HRESULT WINAPI shell32_654 (CABINETSTATE *cs, int length)
1329 {
1330 TRACE("%p %d\n",cs,length);
1331 return ReadCabinetState(cs,length);
1332 }
1333
1334 /************************************************************************
1335 * RLBuildListOfPaths [SHELL32.146]
1336 *
1337 * NOTES
1338 * builds a DPA
1339 */
1340 DWORD WINAPI RLBuildListOfPaths (void)
1341 { FIXME("stub\n");
1342 return 0;
1343 }
1344 /************************************************************************
1345 * SHValidateUNC [SHELL32.173]
1346 *
1347 */
1348 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1349 {
1350 FIXME("0x%08lx 0x%08lx 0x%08lx stub\n",x,y,z);
1351 return 0;
1352 }
1353
1354 /************************************************************************
1355 * DoEnvironmentSubstA [SHELL32.@]
1356 *
1357 */
1358 HRESULT WINAPI DoEnvironmentSubstA(LPSTR x, LPSTR y)
1359 {
1360 FIXME("(%s, %s) stub\n", debugstr_a(x), debugstr_a(y));
1361 return 0;
1362 }
1363
1364 /************************************************************************
1365 * DoEnvironmentSubstW [SHELL32.@]
1366 *
1367 */
1368 HRESULT WINAPI DoEnvironmentSubstW(LPWSTR x, LPWSTR y)
1369 {
1370 FIXME("(%s, %s): stub\n", debugstr_w(x), debugstr_w(y));
1371 return 0;
1372 }
1373
1374 /************************************************************************
1375 * DoEnvironmentSubst [SHELL32.53]
1376 *
1377 */
1378 HRESULT WINAPI DoEnvironmentSubstAW(LPVOID x, LPVOID y)
1379 {
1380 if (SHELL_OsIsUnicode())
1381 return DoEnvironmentSubstW(x, y);
1382 return DoEnvironmentSubstA(x, y);
1383 }
1384
1385 /*************************************************************************
1386 * @ [SHELL32.243]
1387 *
1388 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1389 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1390 *
1391 */
1392
1393 BOOL WINAPI shell32_243(DWORD a, DWORD b)
1394 {
1395 return FALSE;
1396 }
1397
1398 /*************************************************************************
1399 * @ [SHELL32.714]
1400 */
1401 DWORD WINAPI SHELL32_714(LPVOID x)
1402 {
1403 FIXME("(%s)stub\n", debugstr_w(x));
1404 return 0;
1405 }
1406
1407 /*************************************************************************
1408 * SHAddFromPropSheetExtArray [SHELL32.167]
1409 */
1410 DWORD WINAPI SHAddFromPropSheetExtArray(DWORD a, DWORD b, DWORD c)
1411 {
1412 FIXME("(%08lx,%08lx,%08lx)stub\n", a, b, c);
1413 return 0;
1414 }
1415
1416 /*************************************************************************
1417 * SHCreatePropSheetExtArray [SHELL32.168]
1418 */
1419 DWORD WINAPI SHCreatePropSheetExtArray(DWORD a, LPCSTR b, DWORD c)
1420 {
1421 FIXME("(%08lx,%s,%08lx)stub\n", a, debugstr_a(b), c);
1422 return 0;
1423 }
1424
1425 /*************************************************************************
1426 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1427 */
1428 DWORD WINAPI SHReplaceFromPropSheetExtArray(DWORD a, DWORD b, DWORD c, DWORD d)
1429 {
1430 FIXME("(%08lx,%08lx,%08lx,%08lx)stub\n", a, b, c, d);
1431 return 0;
1432 }
1433
1434 /*************************************************************************
1435 * SHDestroyPropSheetExtArray [SHELL32.169]
1436 */
1437 DWORD WINAPI SHDestroyPropSheetExtArray(DWORD a)
1438 {
1439 FIXME("(%08lx)stub\n", a);
1440 return 0;
1441 }
1442
1443 /*************************************************************************
1444 * CIDLData_CreateFromIDArray [SHELL32.83]
1445 *
1446 * Create IDataObject from PIDLs??
1447 */
1448 HRESULT WINAPI CIDLData_CreateFromIDArray(
1449 LPCITEMIDLIST pidlFolder,
1450 DWORD cpidlFiles,
1451 LPCITEMIDLIST *lppidlFiles,
1452 LPDATAOBJECT *ppdataObject)
1453 {
1454 UINT i;
1455 HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */
1456
1457 TRACE("(%p, %ld, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1458 if (TRACE_ON(pidl))
1459 {
1460 pdump (pidlFolder);
1461 for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1462 }
1463 *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1464 lppidlFiles, cpidlFiles);
1465 if (*ppdataObject) return S_OK;
1466 return E_OUTOFMEMORY;
1467 }
1468
1469 /*************************************************************************
1470 * SHCreateStdEnumFmtEtc [SHELL32.74]
1471 *
1472 * NOTES
1473 *
1474 */
1475 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1476 DWORD cFormats,
1477 const FORMATETC *lpFormats,
1478 LPENUMFORMATETC *ppenumFormatetc)
1479 {
1480 IEnumFORMATETC *pef;
1481 HRESULT hRes;
1482 TRACE("cf=%ld fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1483
1484 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1485 if (!pef)
1486 return E_OUTOFMEMORY;
1487
1488 IEnumFORMATETC_AddRef(pef);
1489 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1490 IEnumFORMATETC_Release(pef);
1491
1492 return hRes;
1493 }
1494
1495
1496 /*************************************************************************
1497 * SHELL32_256
1498 */
1499 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1500 {
1501 HRESULT ret = S_OK;
1502
1503 FIXME("stub %p 0x%08lx %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1504
1505 if (!lpdw0 || *lpdw0 != 0x10)
1506 ret = E_INVALIDARG;
1507 else
1508 {
1509 LPVOID lpdata = 0;/*LocalAlloc(GMEM_ZEROINIT, 0x4E4);*/
1510
1511 if (!lpdata)
1512 ret = E_OUTOFMEMORY;
1513 else
1514 {
1515 /* Initialize and return unknown lpdata structure */
1516 }
1517 }
1518
1519 return ret;
1520 }
1521
1522 /*************************************************************************
1523 * SHUpdateImageW (SHELL32.192)
1524 *
1525 * Notifies the shell that an icon in the system image list has been changed.
1526 *
1527 * PARAMS
1528 * pszHashItem [I] Path to file that contains the icon.
1529 * iIndex [I] Zero-based index of the icon in the file.
1530 * uFlags [I] Flags determining the icon attributes. See notes.
1531 * iImageIndex [I] Index of the icon in the system image list.
1532 *
1533 * NOTES
1534 * uFlags can be one or more of the following flags:
1535 * GIL_NOTFILENAME - pszHashItem is not a file name.
1536 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1537 */
1538 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
1539 {
1540 FIXME("%s, %d, 0x%x, %d\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
1541 }