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

Last change on this file since 8266 was 8048, checked in by sandervl, 23 years ago

PH: Wine resync + OS2 integration

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