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