source: trunk/src/shell32/shellord.c@ 10367

Last change on this file since 10367 was 10308, checked in by sandervl, 22 years ago

Wrong if statement in recent SHAddToRecentDocs patch

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