Changes in crossover-wine-src-6.1.0 except for configure
[wine/hacks.git] / dlls / shell32 / shellord.c
blob8fca34e7db296a48b05591192c1baf590e68f25a
1 /*
2 * The parameters of many functions changes between different OS versions
3 * (NT uses Unicode strings, 95 uses ASCII strings)
5 * Copyright 1997 Marcus Meissner
6 * 1998 Jürgen Schmied
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
24 #include <string.h>
25 #include <stdarg.h>
26 #include <stdio.h>
28 #define COBJMACROS
30 #include "winerror.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winreg.h"
34 #include "wine/debug.h"
35 #include "winnls.h"
37 #include "shellapi.h"
38 #include "objbase.h"
39 #include "shlguid.h"
40 #include "wingdi.h"
41 #include "winuser.h"
42 #include "shlobj.h"
43 #include "shell32_main.h"
44 #include "undocshell.h"
45 #include "pidl.h"
46 #include "shlwapi.h"
47 #include "commdlg.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(shell);
50 WINE_DECLARE_DEBUG_CHANNEL(pidl);
52 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
53 /* !!! it is in both here and comctl32undoc.c !!! */
54 typedef struct tagCREATEMRULIST
56 DWORD cbSize; /* size of struct */
57 DWORD nMaxItems; /* max no. of items in list */
58 DWORD dwFlags; /* see below */
59 HKEY hKey; /* root reg. key under which list is saved */
60 LPCSTR lpszSubKey; /* reg. subkey */
61 PROC lpfnCompare; /* item compare proc */
62 } CREATEMRULISTA, *LPCREATEMRULISTA;
64 /* dwFlags */
65 #define MRUF_STRING_LIST 0 /* list will contain strings */
66 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
67 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
69 extern HANDLE WINAPI CreateMRUListA(LPCREATEMRULISTA lpcml);
70 extern DWORD WINAPI FreeMRUList(HANDLE hMRUList);
71 extern INT WINAPI AddMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData);
72 extern INT WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
73 extern INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
76 /* Get a function pointer from a DLL handle */
77 #define GET_FUNC(func, module, name, fail) \
78 do { \
79 if (!func) { \
80 if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
81 func = (void*)GetProcAddress(SHELL32_h##module, name); \
82 if (!func) return fail; \
83 } \
84 } while (0)
86 /* Function pointers for GET_FUNC macro */
87 static HMODULE SHELL32_hshlwapi=NULL;
88 static HANDLE (WINAPI *pSHAllocShared)(LPCVOID,DWORD,DWORD);
89 static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD);
90 static BOOL (WINAPI *pSHUnlockShared)(LPVOID);
91 static BOOL (WINAPI *pSHFreeShared)(HANDLE,DWORD);
94 /*************************************************************************
95 * ParseFieldA [internal]
97 * copies a field from a ',' delimited string
99 * first field is nField = 1
101 DWORD WINAPI ParseFieldA(
102 LPCSTR src,
103 DWORD nField,
104 LPSTR dst,
105 DWORD len)
107 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src),nField,dst,len);
109 if (!src || !src[0] || !dst || !len)
110 return 0;
112 /* skip n fields delimited by ',' */
113 while (nField > 1)
115 if (*src=='\0') return FALSE;
116 if (*(src++)==',') nField--;
119 /* copy part till the next ',' to dst */
120 while ( *src!='\0' && *src!=',' && (len--)>0 ) *(dst++)=*(src++);
122 /* finalize the string */
123 *dst=0x0;
125 return TRUE;
128 /*************************************************************************
129 * ParseFieldW [internal]
131 * copies a field from a ',' delimited string
133 * first field is nField = 1
135 DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len)
137 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src), nField, dst, len);
139 if (!src || !src[0] || !dst || !len)
140 return 0;
142 /* skip n fields delimited by ',' */
143 while (nField > 1)
145 if (*src == 0x0) return FALSE;
146 if (*src++ == ',') nField--;
149 /* copy part till the next ',' to dst */
150 while ( *src != 0x0 && *src != ',' && (len--)>0 ) *(dst++) = *(src++);
152 /* finalize the string */
153 *dst = 0x0;
155 return TRUE;
158 /*************************************************************************
159 * ParseField [SHELL32.58]
161 DWORD WINAPI ParseFieldAW(LPCVOID src, DWORD nField, LPVOID dst, DWORD len)
163 if (SHELL_OsIsUnicode())
164 return ParseFieldW(src, nField, dst, len);
165 return ParseFieldA(src, nField, dst, len);
168 /*************************************************************************
169 * GetFileNameFromBrowse [SHELL32.63]
172 BOOL WINAPI GetFileNameFromBrowse(
173 HWND hwndOwner,
174 LPSTR lpstrFile,
175 DWORD nMaxFile,
176 LPCSTR lpstrInitialDir,
177 LPCSTR lpstrDefExt,
178 LPCSTR lpstrFilter,
179 LPCSTR lpstrTitle)
181 HMODULE hmodule;
182 FARPROC pGetOpenFileNameA;
183 OPENFILENAMEA ofn;
184 BOOL ret;
186 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
187 hwndOwner, lpstrFile, nMaxFile, lpstrInitialDir, lpstrDefExt,
188 lpstrFilter, lpstrTitle);
190 hmodule = LoadLibraryA("comdlg32.dll");
191 if(!hmodule) return FALSE;
192 pGetOpenFileNameA = GetProcAddress(hmodule, "GetOpenFileNameA");
193 if(!pGetOpenFileNameA)
195 FreeLibrary(hmodule);
196 return FALSE;
199 memset(&ofn, 0, sizeof(ofn));
201 ofn.lStructSize = sizeof(ofn);
202 ofn.hwndOwner = hwndOwner;
203 ofn.lpstrFilter = lpstrFilter;
204 ofn.lpstrFile = lpstrFile;
205 ofn.nMaxFile = nMaxFile;
206 ofn.lpstrInitialDir = lpstrInitialDir;
207 ofn.lpstrTitle = lpstrTitle;
208 ofn.lpstrDefExt = lpstrDefExt;
209 ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
210 ret = pGetOpenFileNameA(&ofn);
212 FreeLibrary(hmodule);
213 return ret;
216 /*************************************************************************
217 * SHGetSetSettings [SHELL32.68]
219 VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
221 if(bSet)
223 FIXME("%p 0x%08x TRUE\n", lpss, dwMask);
225 else
227 SHGetSettings((LPSHELLFLAGSTATE)lpss,dwMask);
231 /*************************************************************************
232 * SHGetSettings [SHELL32.@]
234 * NOTES
235 * the registry path are for win98 (tested)
236 * and possibly are the same in nt40
239 VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask)
241 HKEY hKey;
242 DWORD dwData;
243 DWORD dwDataSize = sizeof (DWORD);
245 TRACE("(%p 0x%08x)\n",lpsfs,dwMask);
247 if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
248 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0))
249 return;
251 if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize))
252 lpsfs->fShowExtensions = ((dwData == 0) ? 0 : 1);
254 if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize))
255 lpsfs->fShowInfoTip = ((dwData == 0) ? 0 : 1);
257 if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize))
258 lpsfs->fDontPrettyPath = ((dwData == 0) ? 0 : 1);
260 if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize))
261 lpsfs->fHideIcons = ((dwData == 0) ? 0 : 1);
263 if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize))
264 lpsfs->fMapNetDrvBtn = ((dwData == 0) ? 0 : 1);
266 if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize))
267 lpsfs->fShowAttribCol = ((dwData == 0) ? 0 : 1);
269 if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize))
270 { if (dwData == 0)
271 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
272 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
274 else if (dwData == 1)
275 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 1;
276 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
278 else if (dwData == 2)
279 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
280 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 1;
283 RegCloseKey (hKey);
285 TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
288 /*************************************************************************
289 * SHShellFolderView_Message [SHELL32.73]
291 * Send a message to an explorer cabinet window.
293 * PARAMS
294 * hwndCabinet [I] The window containing the shellview to communicate with
295 * dwMessage [I] The SFVM message to send
296 * dwParam [I] Message parameter
298 * RETURNS
299 * fixme.
301 * NOTES
302 * Message SFVM_REARRANGE = 1
304 * This message gets sent when a column gets clicked to instruct the
305 * shell view to re-sort the item list. dwParam identifies the column
306 * that was clicked.
308 LRESULT WINAPI SHShellFolderView_Message(
309 HWND hwndCabinet,
310 UINT uMessage,
311 LPARAM lParam)
313 FIXME("%p %08x %08lx stub\n",hwndCabinet, uMessage, lParam);
314 return 0;
317 /*************************************************************************
318 * RegisterShellHook [SHELL32.181]
320 * Register a shell hook.
322 * PARAMS
323 * hwnd [I] Window handle
324 * dwType [I] Type of hook.
326 * NOTES
327 * Exported by ordinal
329 BOOL WINAPI RegisterShellHook(
330 HWND hWnd,
331 DWORD dwType)
333 FIXME("(%p,0x%08x):stub.\n",hWnd, dwType);
334 return TRUE;
337 /*************************************************************************
338 * ShellMessageBoxW [SHELL32.182]
340 * See ShellMessageBoxA.
342 int WINAPIV ShellMessageBoxW(
343 HINSTANCE hInstance,
344 HWND hWnd,
345 LPCWSTR lpText,
346 LPCWSTR lpCaption,
347 UINT uType,
348 ...)
350 WCHAR szText[100],szTitle[100];
351 LPCWSTR pszText = szText, pszTitle = szTitle;
352 LPWSTR pszTemp;
353 va_list args;
354 int ret;
356 va_start(args, uType);
357 /* wvsprintfA(buf,fmt, args); */
359 TRACE("(%p,%p,%p,%p,%08x)\n",
360 hInstance,hWnd,lpText,lpCaption,uType);
362 if (IS_INTRESOURCE(lpCaption))
363 LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
364 else
365 pszTitle = lpCaption;
367 if (IS_INTRESOURCE(lpText))
368 LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
369 else
370 pszText = lpText;
372 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
373 pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
375 va_end(args);
377 ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
378 LocalFree((HLOCAL)pszTemp);
379 return ret;
382 /*************************************************************************
383 * ShellMessageBoxA [SHELL32.183]
385 * Format and output an error message.
387 * PARAMS
388 * hInstance [I] Instance handle of message creator
389 * hWnd [I] Window handle of message creator
390 * lpText [I] Resource Id of title or LPSTR
391 * lpCaption [I] Resource Id of title or LPSTR
392 * uType [I] Type of error message
394 * RETURNS
395 * A return value from MessageBoxA().
397 * NOTES
398 * Exported by ordinal
400 int WINAPIV ShellMessageBoxA(
401 HINSTANCE hInstance,
402 HWND hWnd,
403 LPCSTR lpText,
404 LPCSTR lpCaption,
405 UINT uType,
406 ...)
408 char szText[100],szTitle[100];
409 LPCSTR pszText = szText, pszTitle = szTitle;
410 LPSTR pszTemp;
411 va_list args;
412 int ret;
414 va_start(args, uType);
415 /* wvsprintfA(buf,fmt, args); */
417 TRACE("(%p,%p,%p,%p,%08x)\n",
418 hInstance,hWnd,lpText,lpCaption,uType);
420 if (IS_INTRESOURCE(lpCaption))
421 LoadStringA(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle));
422 else
423 pszTitle = lpCaption;
425 if (IS_INTRESOURCE(lpText))
426 LoadStringA(hInstance, LOWORD(lpText), szText, sizeof(szText));
427 else
428 pszText = lpText;
430 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
431 pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
433 va_end(args);
435 ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
436 LocalFree((HLOCAL)pszTemp);
437 return ret;
440 /*************************************************************************
441 * SHRegisterDragDrop [SHELL32.86]
443 * Probably equivalent to RegisterDragDrop but under Windows 9x it could use the
444 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
445 * for details
447 * NOTES
448 * exported by ordinal
450 * SEE ALSO
451 * RegisterDragDrop, SHLoadOLE
453 HRESULT WINAPI SHRegisterDragDrop(
454 HWND hWnd,
455 LPDROPTARGET pDropTarget)
457 FIXME("(%p,%p):stub.\n", hWnd, pDropTarget);
458 return RegisterDragDrop(hWnd, pDropTarget);
461 /*************************************************************************
462 * SHRevokeDragDrop [SHELL32.87]
464 * Probably equivalent to RevokeDragDrop but under Windows 9x it could use the
465 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
466 * for details
468 * NOTES
469 * exported by ordinal
471 * SEE ALSO
472 * RevokeDragDrop, SHLoadOLE
474 HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
476 FIXME("(%p):stub.\n",hWnd);
477 return RevokeDragDrop(hWnd);
480 /*************************************************************************
481 * SHDoDragDrop [SHELL32.88]
483 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
484 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
485 * for details
487 * NOTES
488 * exported by ordinal
490 * SEE ALSO
491 * DoDragDrop, SHLoadOLE
493 HRESULT WINAPI SHDoDragDrop(
494 HWND hWnd,
495 LPDATAOBJECT lpDataObject,
496 LPDROPSOURCE lpDropSource,
497 DWORD dwOKEffect,
498 LPDWORD pdwEffect)
500 FIXME("(%p %p %p 0x%08x %p):stub.\n",
501 hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
502 return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
505 /*************************************************************************
506 * ArrangeWindows [SHELL32.184]
509 WORD WINAPI ArrangeWindows(
510 HWND hwndParent,
511 DWORD dwReserved,
512 LPCRECT lpRect,
513 WORD cKids,
514 CONST HWND * lpKids)
516 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
517 hwndParent, dwReserved, lpRect, cKids, lpKids);
518 return 0;
521 /*************************************************************************
522 * SignalFileOpen [SHELL32.103]
524 * NOTES
525 * exported by ordinal
527 DWORD WINAPI
528 SignalFileOpen (DWORD dwParam1)
530 FIXME("(0x%08x):stub.\n", dwParam1);
532 return 0;
535 /*************************************************************************
536 * SHADD_get_policy - helper function for SHAddToRecentDocs
538 * PARAMETERS
539 * policy [IN] policy name (null termed string) to find
540 * type [OUT] ptr to DWORD to receive type
541 * buffer [OUT] ptr to area to hold data retrieved
542 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
543 * length filled
545 * RETURNS
546 * result of the SHQueryValueEx call
548 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
550 HKEY Policy_basekey;
551 INT ret;
553 /* Get the key for the policies location in the registry
555 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
556 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
557 0, KEY_READ, &Policy_basekey)) {
559 if (RegOpenKeyExA(HKEY_CURRENT_USER,
560 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
561 0, KEY_READ, &Policy_basekey)) {
562 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
563 policy);
564 *len = 0;
565 return ERROR_FILE_NOT_FOUND;
569 /* Retrieve the data if it exists
571 ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len);
572 RegCloseKey(Policy_basekey);
573 return ret;
577 /*************************************************************************
578 * SHADD_compare_mru - helper function for SHAddToRecentDocs
580 * PARAMETERS
581 * data1 [IN] data being looked for
582 * data2 [IN] data in MRU
583 * cbdata [IN] length from FindMRUData call (not used)
585 * RETURNS
586 * position within MRU list that data was added.
588 static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData)
590 return lstrcmpiA(data1, data2);
593 /*************************************************************************
594 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
596 * PARAMETERS
597 * mruhandle [IN] handle for created MRU list
598 * doc_name [IN] null termed pure doc name
599 * new_lnk_name [IN] null termed path and file name for .lnk file
600 * buffer [IN/OUT] 2048 byte area to construct MRU data
601 * len [OUT] ptr to int to receive space used in buffer
603 * RETURNS
604 * position within MRU list that data was added.
606 static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPSTR doc_name, LPSTR new_lnk_name,
607 LPSTR buffer, INT *len)
609 LPSTR ptr;
610 INT wlen;
612 /*FIXME: Document:
613 * RecentDocs MRU data structure seems to be:
614 * +0h document file name w/ terminating 0h
615 * +nh short int w/ size of remaining
616 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
617 * +n+4h 10 bytes zeros - unknown
618 * +n+eh shortcut file name w/ terminating 0h
619 * +n+e+nh 3 zero bytes - unknown
622 /* Create the MRU data structure for "RecentDocs"
624 ptr = buffer;
625 lstrcpyA(ptr, doc_name);
626 ptr += (lstrlenA(buffer) + 1);
627 wlen= lstrlenA(new_lnk_name) + 1 + 12;
628 *((short int*)ptr) = wlen;
629 ptr += 2; /* step past the length */
630 *(ptr++) = 0x30; /* unknown reason */
631 *(ptr++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
632 memset(ptr, 0, 10);
633 ptr += 10;
634 lstrcpyA(ptr, new_lnk_name);
635 ptr += (lstrlenA(new_lnk_name) + 1);
636 memset(ptr, 0, 3);
637 ptr += 3;
638 *len = ptr - buffer;
640 /* Add the new entry into the MRU list
642 return AddMRUData(mruhandle, (LPCVOID)buffer, *len);
645 /*************************************************************************
646 * SHAddToRecentDocs [SHELL32.@]
648 * Modify (add/clear) Shell's list of recently used documents.
650 * PARAMETERS
651 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
652 * pv [IN] string or pidl, NULL clears the list
654 * NOTES
655 * exported by name
657 * FIXME
658 * convert to unicode
660 void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
662 /* If list is a string list lpfnCompare has the following prototype
663 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
664 * for binary lists the prototype is
665 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
666 * where cbData is the no. of bytes to compare.
667 * Need to check what return value means identical - 0?
671 UINT olderrormode;
672 HKEY HCUbasekey;
673 CHAR doc_name[MAX_PATH];
674 CHAR link_dir[MAX_PATH];
675 CHAR new_lnk_filepath[MAX_PATH];
676 CHAR new_lnk_name[MAX_PATH];
677 IMalloc *ppM;
678 LPITEMIDLIST pidl;
679 HWND hwnd = 0; /* FIXME: get real window handle */
680 INT ret;
681 DWORD data[64], datalen, type;
683 TRACE("%04x %p\n", uFlags, pv);
685 /*FIXME: Document:
686 * RecentDocs MRU data structure seems to be:
687 * +0h document file name w/ terminating 0h
688 * +nh short int w/ size of remaining
689 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
690 * +n+4h 10 bytes zeros - unknown
691 * +n+eh shortcut file name w/ terminating 0h
692 * +n+e+nh 3 zero bytes - unknown
695 /* See if we need to do anything.
697 datalen = 64;
698 ret=SHADD_get_policy( "NoRecentDocsHistory", &type, &data, &datalen);
699 if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) {
700 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret);
701 return;
703 if (ret == ERROR_SUCCESS) {
704 if (!( (type == REG_DWORD) ||
705 ((type == REG_BINARY) && (datalen == 4)) )) {
706 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
707 type, datalen);
708 return;
711 TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
712 /* now test the actual policy value */
713 if ( data[0] != 0)
714 return;
717 /* Open key to where the necessary info is
719 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
720 * and the close should be done during the _DETACH. The resulting
721 * key is stored in the DLL global data.
723 if (RegCreateKeyExA(HKEY_CURRENT_USER,
724 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
725 0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
726 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
727 return;
730 /* Get path to user's "Recent" directory
732 if(SUCCEEDED(SHGetMalloc(&ppM))) {
733 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
734 &pidl))) {
735 SHGetPathFromIDListA(pidl, link_dir);
736 IMalloc_Free(ppM, pidl);
738 else {
739 /* serious issues */
740 link_dir[0] = 0;
741 ERR("serious issues 1\n");
743 IMalloc_Release(ppM);
745 else {
746 /* serious issues */
747 link_dir[0] = 0;
748 ERR("serious issues 2\n");
750 TRACE("Users Recent dir %s\n", link_dir);
752 /* If no input, then go clear the lists */
753 if (!pv) {
754 /* clear user's Recent dir
757 /* FIXME: delete all files in "link_dir"
759 * while( more files ) {
760 * lstrcpyA(old_lnk_name, link_dir);
761 * PathAppendA(old_lnk_name, filenam);
762 * DeleteFileA(old_lnk_name);
765 FIXME("should delete all files in %s\\\n", link_dir);
767 /* clear MRU list
769 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
770 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
771 * and naturally it fails w/ rc=2. It should do it against
772 * HKEY_CURRENT_USER which is where it is stored, and where
773 * the MRU routines expect it!!!!
775 RegDeleteKeyA(HCUbasekey, "RecentDocs");
776 RegCloseKey(HCUbasekey);
777 return;
780 /* Have data to add, the jobs to be done:
781 * 1. Add document to MRU list in registry "HKCU\Software\
782 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
783 * 2. Add shortcut to document in the user's Recent directory
784 * (CSIDL_RECENT).
785 * 3. Add shortcut to Start menu's Documents submenu.
788 /* Get the pure document name from the input
790 switch (uFlags)
792 case SHARD_PIDL:
793 if (!SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name))
795 ERR("Unable to get pure document name from pidl\n");
796 return;
798 break;
800 case SHARD_PATHA:
801 lstrcpynA(doc_name, (LPCSTR)pv, MAX_PATH);
802 break;
804 case SHARD_PATHW:
805 WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pv, -1, doc_name, MAX_PATH, NULL, NULL);
806 break;
808 default:
809 FIXME("Unsupported flags: %u\n", uFlags);
810 return;
813 TRACE("full document name %s\n", debugstr_a(doc_name));
814 PathStripPathA(doc_name);
815 TRACE("stripped document name %s\n", debugstr_a(doc_name));
818 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
820 { /* on input needs:
821 * doc_name - pure file-spec, no path
822 * link_dir - path to the user's Recent directory
823 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
824 * creates:
825 * new_lnk_name- pure file-spec, no path for new .lnk file
826 * new_lnk_filepath
827 * - path and file name of new .lnk file
829 CREATEMRULISTA mymru;
830 HANDLE mruhandle;
831 INT len, pos, bufused, err;
832 INT i;
833 DWORD attr;
834 CHAR buffer[2048];
835 CHAR *ptr;
836 CHAR old_lnk_name[MAX_PATH];
837 short int slen;
839 mymru.cbSize = sizeof(CREATEMRULISTA);
840 mymru.nMaxItems = 15;
841 mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE;
842 mymru.hKey = HCUbasekey;
843 mymru.lpszSubKey = "RecentDocs";
844 mymru.lpfnCompare = &SHADD_compare_mru;
845 mruhandle = CreateMRUListA(&mymru);
846 if (!mruhandle) {
847 /* MRU failed */
848 ERR("MRU processing failed, handle zero\n");
849 RegCloseKey(HCUbasekey);
850 return;
852 len = lstrlenA(doc_name);
853 pos = FindMRUData(mruhandle, doc_name, len, 0);
855 /* Now get the MRU entry that will be replaced
856 * and delete the .lnk file for it
858 if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos,
859 buffer, 2048)) != -1) {
860 ptr = buffer;
861 ptr += (lstrlenA(buffer) + 1);
862 slen = *((short int*)ptr);
863 ptr += 2; /* skip the length area */
864 if (bufused >= slen + (ptr-buffer)) {
865 /* buffer size looks good */
866 ptr += 12; /* get to string */
867 len = bufused - (ptr-buffer); /* get length of buf remaining */
868 if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
869 /* appears to be good string */
870 lstrcpyA(old_lnk_name, link_dir);
871 PathAppendA(old_lnk_name, ptr);
872 if (!DeleteFileA(old_lnk_name)) {
873 if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
874 if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
875 ERR("Delete for %s failed, err=%d, attr=%08x\n",
876 old_lnk_name, err, attr);
878 else {
879 TRACE("old .lnk file %s did not exist\n",
880 old_lnk_name);
883 else {
884 ERR("Delete for %s failed, attr=%08x\n",
885 old_lnk_name, attr);
888 else {
889 TRACE("deleted old .lnk file %s\n", old_lnk_name);
895 /* Create usable .lnk file name for the "Recent" directory
897 wsprintfA(new_lnk_name, "%s.lnk", doc_name);
898 lstrcpyA(new_lnk_filepath, link_dir);
899 PathAppendA(new_lnk_filepath, new_lnk_name);
900 i = 1;
901 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
902 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
903 i++;
904 wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
905 lstrcpyA(new_lnk_filepath, link_dir);
906 PathAppendA(new_lnk_filepath, new_lnk_name);
908 SetErrorMode(olderrormode);
909 TRACE("new shortcut will be %s\n", new_lnk_filepath);
911 /* Now add the new MRU entry and data
913 pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name,
914 buffer, &len);
915 FreeMRUList(mruhandle);
916 TRACE("Updated MRU list, new doc is position %d\n", pos);
919 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
921 { /* on input needs:
922 * doc_name - pure file-spec, no path
923 * new_lnk_filepath
924 * - path and file name of new .lnk file
925 * uFlags[in] - flags on call to SHAddToRecentDocs
926 * pv[in] - document path/pidl on call to SHAddToRecentDocs
928 IShellLinkA *psl = NULL;
929 IPersistFile *pPf = NULL;
930 HRESULT hres;
931 CHAR desc[MAX_PATH];
932 WCHAR widelink[MAX_PATH];
934 CoInitialize(0);
936 hres = CoCreateInstance( &CLSID_ShellLink,
937 NULL,
938 CLSCTX_INPROC_SERVER,
939 &IID_IShellLinkA,
940 (LPVOID )&psl);
941 if(SUCCEEDED(hres)) {
943 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
944 (LPVOID *)&pPf);
945 if(FAILED(hres)) {
946 /* bombed */
947 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
948 goto fail;
951 /* Set the document path or pidl */
952 if (uFlags == SHARD_PIDL) {
953 hres = IShellLinkA_SetIDList(psl, (LPCITEMIDLIST) pv);
954 } else {
955 hres = IShellLinkA_SetPath(psl, (LPCSTR) pv);
957 if(FAILED(hres)) {
958 /* bombed */
959 ERR("failed Set{IDList|Path} %08x\n", hres);
960 goto fail;
963 lstrcpyA(desc, "Shortcut to ");
964 lstrcatA(desc, doc_name);
965 hres = IShellLinkA_SetDescription(psl, desc);
966 if(FAILED(hres)) {
967 /* bombed */
968 ERR("failed SetDescription %08x\n", hres);
969 goto fail;
972 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
973 widelink, MAX_PATH);
974 /* create the short cut */
975 hres = IPersistFile_Save(pPf, widelink, TRUE);
976 if(FAILED(hres)) {
977 /* bombed */
978 ERR("failed IPersistFile::Save %08x\n", hres);
979 IPersistFile_Release(pPf);
980 IShellLinkA_Release(psl);
981 goto fail;
983 hres = IPersistFile_SaveCompleted(pPf, widelink);
984 IPersistFile_Release(pPf);
985 IShellLinkA_Release(psl);
986 TRACE("shortcut %s has been created, result=%08x\n",
987 new_lnk_filepath, hres);
989 else {
990 ERR("CoCreateInstance failed, hres=%08x\n", hres);
994 fail:
995 CoUninitialize();
997 /* all done */
998 RegCloseKey(HCUbasekey);
999 return;
1002 /*************************************************************************
1003 * SHCreateShellFolderViewEx [SHELL32.174]
1005 * Create a new instance of the default Shell folder view object.
1007 * RETURNS
1008 * Success: S_OK
1009 * Failure: error value
1011 * NOTES
1012 * see IShellFolder::CreateViewObject
1014 HRESULT WINAPI SHCreateShellFolderViewEx(
1015 LPCSFV psvcbi, /* [in] shelltemplate struct */
1016 IShellView **ppv) /* [out] IShellView pointer */
1018 IShellView * psf;
1019 HRESULT hRes;
1021 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1022 psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
1023 psvcbi->fvm, psvcbi->psvOuter);
1025 psf = IShellView_Constructor(psvcbi->pshf);
1027 if (!psf)
1028 return E_OUTOFMEMORY;
1030 IShellView_AddRef(psf);
1031 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1032 IShellView_Release(psf);
1034 return hRes;
1036 /*************************************************************************
1037 * SHWinHelp [SHELL32.127]
1040 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
1041 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v,w,x,z);
1042 return 0;
1044 /*************************************************************************
1045 * SHRunControlPanel [SHELL32.161]
1048 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
1049 { FIXME("0x%08x 0x%08x stub\n",x,z);
1050 return 0;
1053 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1054 /*************************************************************************
1055 * SHSetInstanceExplorer [SHELL32.176]
1057 * NOTES
1058 * Sets the interface
1060 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1061 { TRACE("%p\n", lpUnknown);
1062 SHELL32_IExplorerInterface = lpUnknown;
1064 /*************************************************************************
1065 * SHGetInstanceExplorer [SHELL32.@]
1067 * NOTES
1068 * gets the interface pointer of the explorer and a reference
1070 HRESULT WINAPI SHGetInstanceExplorer (IUnknown **lpUnknown)
1071 { TRACE("%p\n", lpUnknown);
1073 *lpUnknown = SHELL32_IExplorerInterface;
1075 if (!SHELL32_IExplorerInterface)
1076 return E_FAIL;
1078 IUnknown_AddRef(SHELL32_IExplorerInterface);
1079 return NOERROR;
1081 /*************************************************************************
1082 * SHFreeUnusedLibraries [SHELL32.123]
1084 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1085 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1086 * for details
1088 * NOTES
1089 * exported by ordinal
1091 * SEE ALSO
1092 * CoFreeUnusedLibraries, SHLoadOLE
1094 void WINAPI SHFreeUnusedLibraries (void)
1096 FIXME("stub\n");
1097 CoFreeUnusedLibraries();
1099 /*************************************************************************
1100 * DAD_AutoScroll [SHELL32.129]
1103 BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, LPPOINT pt)
1105 FIXME("hwnd = %p %p %p\n",hwnd,samples,pt);
1106 return 0;
1108 /*************************************************************************
1109 * DAD_DragEnter [SHELL32.130]
1112 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1114 FIXME("hwnd = %p\n",hwnd);
1115 return FALSE;
1117 /*************************************************************************
1118 * DAD_DragEnterEx [SHELL32.131]
1121 BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p)
1123 FIXME("hwnd = %p (%d,%d)\n",hwnd,p.x,p.y);
1124 return FALSE;
1126 /*************************************************************************
1127 * DAD_DragMove [SHELL32.134]
1130 BOOL WINAPI DAD_DragMove(POINT p)
1132 FIXME("(%d,%d)\n",p.x,p.y);
1133 return FALSE;
1135 /*************************************************************************
1136 * DAD_DragLeave [SHELL32.132]
1139 BOOL WINAPI DAD_DragLeave(VOID)
1141 FIXME("\n");
1142 return FALSE;
1144 /*************************************************************************
1145 * DAD_SetDragImage [SHELL32.136]
1147 * NOTES
1148 * exported by name
1150 BOOL WINAPI DAD_SetDragImage(
1151 HIMAGELIST himlTrack,
1152 LPPOINT lppt)
1154 FIXME("%p %p stub\n",himlTrack, lppt);
1155 return 0;
1157 /*************************************************************************
1158 * DAD_ShowDragImage [SHELL32.137]
1160 * NOTES
1161 * exported by name
1163 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1165 FIXME("0x%08x stub\n",bShow);
1166 return 0;
1169 static const WCHAR szwCabLocation[] = {
1170 'S','o','f','t','w','a','r','e','\\',
1171 'M','i','c','r','o','s','o','f','t','\\',
1172 'W','i','n','d','o','w','s','\\',
1173 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1174 'E','x','p','l','o','r','e','r','\\',
1175 'C','a','b','i','n','e','t','S','t','a','t','e',0
1178 static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 };
1180 /*************************************************************************
1181 * ReadCabinetState [SHELL32.651] NT 4.0
1184 BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
1186 HKEY hkey = 0;
1187 DWORD type, r;
1189 TRACE("%p %d\n", cs, length);
1191 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1192 return FALSE;
1194 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1195 if( r == ERROR_SUCCESS )
1197 type = REG_BINARY;
1198 r = RegQueryValueExW( hkey, szwSettings,
1199 NULL, &type, (LPBYTE)cs, (LPDWORD)&length );
1200 RegCloseKey( hkey );
1204 /* if we can't read from the registry, create default values */
1205 if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) ||
1206 (cs->cLength != length) )
1208 ERR("Initializing shell cabinet settings\n");
1209 memset(cs, 0, sizeof(*cs));
1210 cs->cLength = sizeof(*cs);
1211 cs->nVersion = 2;
1212 cs->fFullPathTitle = FALSE;
1213 cs->fSaveLocalView = TRUE;
1214 cs->fNotShell = FALSE;
1215 cs->fSimpleDefault = TRUE;
1216 cs->fDontShowDescBar = FALSE;
1217 cs->fNewWindowMode = FALSE;
1218 cs->fShowCompColor = FALSE;
1219 cs->fDontPrettyNames = FALSE;
1220 cs->fAdminsCreateCommonGroups = TRUE;
1221 cs->fMenuEnumFilter = 96;
1224 return TRUE;
1227 /*************************************************************************
1228 * WriteCabinetState [SHELL32.652] NT 4.0
1231 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1233 DWORD r;
1234 HKEY hkey = 0;
1236 TRACE("%p\n",cs);
1238 if( cs == NULL )
1239 return FALSE;
1241 r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0,
1242 NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
1243 if( r == ERROR_SUCCESS )
1245 r = RegSetValueExW( hkey, szwSettings, 0,
1246 REG_BINARY, (LPBYTE) cs, cs->cLength);
1248 RegCloseKey( hkey );
1251 return (r==ERROR_SUCCESS);
1254 /*************************************************************************
1255 * FileIconInit [SHELL32.660]
1258 BOOL WINAPI FileIconInit(BOOL bFullInit)
1259 { FIXME("(%s)\n", bFullInit ? "true" : "false");
1260 return 0;
1262 /*************************************************************************
1263 * IsUserAdmin [SHELL32.680] NT 4.0
1266 HRESULT WINAPI IsUserAdmin(void)
1267 { FIXME("stub\n");
1268 return TRUE;
1271 /*************************************************************************
1272 * SHAllocShared [SHELL32.520]
1274 * See shlwapi.SHAllocShared
1276 HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
1278 GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
1279 return pSHAllocShared(lpvData, dwSize, dwProcId);
1282 /*************************************************************************
1283 * SHLockShared [SHELL32.521]
1285 * See shlwapi.SHLockShared
1287 LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
1289 GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
1290 return pSHLockShared(hShared, dwProcId);
1293 /*************************************************************************
1294 * SHUnlockShared [SHELL32.522]
1296 * See shlwapi.SHUnlockShared
1298 BOOL WINAPI SHUnlockShared(LPVOID lpView)
1300 GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
1301 return pSHUnlockShared(lpView);
1304 /*************************************************************************
1305 * SHFreeShared [SHELL32.523]
1307 * See shlwapi.SHFreeShared
1309 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
1311 GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
1312 return pSHFreeShared(hShared, dwProcId);
1315 /*************************************************************************
1316 * SetAppStartingCursor [SHELL32.99]
1318 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1319 { FIXME("hwnd=%p 0x%04x stub\n",u,v );
1320 return 0;
1323 /*************************************************************************
1324 * SHLoadOLE [SHELL32.151]
1326 * To reduce the memory usage of Windows 95, its shell32 contained an
1327 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1328 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1329 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1330 * would just call the Co* functions.
1332 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1333 * information from the shell32 "mini-COM" to ole32.dll.
1335 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1336 * detailed description.
1338 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1339 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1340 * hack in SHCoCreateInstance)
1342 HRESULT WINAPI SHLoadOLE(LPARAM lParam)
1343 { FIXME("0x%08lx stub\n",lParam);
1344 return S_OK;
1346 /*************************************************************************
1347 * DriveType [SHELL32.64]
1350 HRESULT WINAPI DriveType(DWORD u)
1351 { FIXME("0x%04x stub\n",u);
1352 return 0;
1354 /*************************************************************************
1355 * InvalidateDriveType [SHELL32.65]
1358 int WINAPI InvalidateDriveType(int u)
1359 { FIXME("0x%08x stub\n",u);
1360 return 0;
1362 /*************************************************************************
1363 * SHAbortInvokeCommand [SHELL32.198]
1366 HRESULT WINAPI SHAbortInvokeCommand(void)
1367 { FIXME("stub\n");
1368 return 1;
1370 /*************************************************************************
1371 * SHOutOfMemoryMessageBox [SHELL32.126]
1374 int WINAPI SHOutOfMemoryMessageBox(
1375 HWND hwndOwner,
1376 LPCSTR lpCaption,
1377 UINT uType)
1379 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1380 return 0;
1382 /*************************************************************************
1383 * SHFlushClipboard [SHELL32.121]
1386 HRESULT WINAPI SHFlushClipboard(void)
1387 { FIXME("stub\n");
1388 return 1;
1391 /*************************************************************************
1392 * SHWaitForFileToOpen [SHELL32.97]
1395 BOOL WINAPI SHWaitForFileToOpen(
1396 LPCITEMIDLIST pidl,
1397 DWORD dwFlags,
1398 DWORD dwTimeout)
1400 FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1401 return 0;
1404 /************************************************************************
1405 * @ [SHELL32.654]
1407 * NOTES
1408 * first parameter seems to be a pointer (same as passed to WriteCabinetState)
1409 * second one could be a size (0x0c). The size is the same as the structure saved to
1410 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1411 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1413 HRESULT WINAPI shell32_654 (CABINETSTATE *cs, int length)
1415 TRACE("%p %d\n",cs,length);
1416 return ReadCabinetState(cs,length);
1419 /************************************************************************
1420 * RLBuildListOfPaths [SHELL32.146]
1422 * NOTES
1423 * builds a DPA
1425 DWORD WINAPI RLBuildListOfPaths (void)
1426 { FIXME("stub\n");
1427 return 0;
1429 /************************************************************************
1430 * SHValidateUNC [SHELL32.173]
1433 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1435 FIXME("0x%08x 0x%08x 0x%08x stub\n",x,y,z);
1436 return 0;
1439 /************************************************************************
1440 * DoEnvironmentSubstA [SHELL32.@]
1442 * Replace %KEYWORD% in the str with the value of variable KEYWORD
1443 * from environment. If it is not found the %KEYWORD% is left
1444 * intact. If the buffer is too small, str is not modified.
1446 * PARAMS
1447 * pszString [I] '\0' terminated string with %keyword%.
1448 * [O] '\0' terminated string with %keyword% substituted.
1449 * cchString [I] size of str.
1451 * RETURNS
1452 * cchString length in the HIWORD;
1453 * TRUE in LOWORD if subst was successful and FALSE in other case
1455 DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
1457 LPSTR dst;
1458 BOOL res = FALSE;
1459 FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
1460 if (pszString == NULL) /* Really return 0? */
1461 return 0;
1462 if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
1464 DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
1465 if (num && num < cchString) /* dest buffer is too small */
1467 res = TRUE;
1468 memcpy(pszString, dst, num);
1470 HeapFree(GetProcessHeap(), 0, dst);
1472 return MAKELONG(res,cchString); /* Always cchString? */
1475 /************************************************************************
1476 * DoEnvironmentSubstW [SHELL32.@]
1478 * See DoEnvironmentSubstA.
1480 DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
1482 FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
1483 return MAKELONG(FALSE,cchString);
1486 /************************************************************************
1487 * DoEnvironmentSubst [SHELL32.53]
1489 * See DoEnvironmentSubstA.
1491 DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y)
1493 if (SHELL_OsIsUnicode())
1494 return DoEnvironmentSubstW(x, y);
1495 return DoEnvironmentSubstA(x, y);
1498 /*************************************************************************
1499 * @ [SHELL32.243]
1501 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1502 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1506 BOOL WINAPI shell32_243(DWORD a, DWORD b)
1508 return FALSE;
1511 /*************************************************************************
1512 * @ [SHELL32.714]
1514 DWORD WINAPI SHELL32_714(LPVOID x)
1516 FIXME("(%s)stub\n", debugstr_w(x));
1517 return 0;
1520 typedef struct _PSXA
1522 UINT uiCount;
1523 UINT uiAllocated;
1524 IShellPropSheetExt *pspsx[1];
1525 } PSXA, *PPSXA;
1527 typedef struct _PSXA_CALL
1529 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith;
1530 LPARAM lParam;
1531 BOOL bCalled;
1532 BOOL bMultiple;
1533 UINT uiCount;
1534 } PSXA_CALL, *PPSXA_CALL;
1536 static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam)
1538 PPSXA_CALL Call = (PPSXA_CALL)lParam;
1540 if (Call != NULL)
1542 if ((Call->bMultiple || !Call->bCalled) &&
1543 Call->lpfnAddReplaceWith(hpage, Call->lParam))
1545 Call->bCalled = TRUE;
1546 Call->uiCount++;
1547 return TRUE;
1551 return FALSE;
1554 /*************************************************************************
1555 * SHAddFromPropSheetExtArray [SHELL32.167]
1557 UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
1559 PSXA_CALL Call;
1560 UINT i;
1561 PPSXA psxa = (PPSXA)hpsxa;
1563 TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam);
1565 if (psxa)
1567 ZeroMemory(&Call, sizeof(Call));
1568 Call.lpfnAddReplaceWith = lpfnAddPage;
1569 Call.lParam = lParam;
1570 Call.bMultiple = TRUE;
1572 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1573 for (i = 0; i != psxa->uiCount; i++)
1575 psxa->pspsx[i]->lpVtbl->AddPages(psxa->pspsx[i], PsxaCall, (LPARAM)&Call);
1578 return Call.uiCount;
1581 return 0;
1584 /*************************************************************************
1585 * SHCreatePropSheetExtArray [SHELL32.168]
1587 HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
1589 static const WCHAR szPropSheetSubKey[] = {'s','h','e','l','l','e','x','\\','P','r','o','p','e','r','t','y','S','h','e','e','t','H','a','n','d','l','e','r','s',0};
1590 WCHAR szHandler[64];
1591 DWORD dwHandlerLen;
1592 WCHAR szClsidHandler[39];
1593 DWORD dwClsidSize;
1594 CLSID clsid;
1595 LONG lRet;
1596 DWORD dwIndex;
1597 IShellExtInit *psxi;
1598 IShellPropSheetExt *pspsx;
1599 HKEY hkBase, hkPropSheetHandlers;
1600 PPSXA psxa = NULL;
1602 TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface);
1604 if (max_iface == 0)
1605 return NULL;
1607 /* Open the registry key */
1608 lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase);
1609 if (lRet != ERROR_SUCCESS)
1610 return NULL;
1612 lRet = RegOpenKeyExW(hkBase, szPropSheetSubKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkPropSheetHandlers);
1613 RegCloseKey(hkBase);
1614 if (lRet == ERROR_SUCCESS)
1616 /* Create and initialize the Property Sheet Extensions Array */
1617 psxa = (PPSXA)LocalAlloc(LMEM_FIXED, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1618 if (psxa)
1620 ZeroMemory(psxa, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1621 psxa->uiAllocated = max_iface;
1623 /* Enumerate all subkeys and attempt to load the shell extensions */
1624 dwIndex = 0;
1627 dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]);
1628 lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL);
1629 if (lRet != ERROR_SUCCESS)
1631 if (lRet == ERROR_MORE_DATA)
1632 continue;
1634 if (lRet == ERROR_NO_MORE_ITEMS)
1635 lRet = ERROR_SUCCESS;
1636 break;
1639 dwClsidSize = sizeof(szClsidHandler);
1640 if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
1642 /* Force a NULL-termination and convert the string */
1643 szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
1644 if (SUCCEEDED(SHCLSIDFromStringW(szClsidHandler, &clsid)))
1646 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1647 Only if both interfaces are supported it's a real shell extension.
1648 Then call IShellExtInit's Initialize method. */
1649 if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx)))
1651 if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi)))
1653 if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, NULL, hKey)))
1655 /* Add the IShellPropSheetExt instance to the array */
1656 psxa->pspsx[psxa->uiCount++] = pspsx;
1658 else
1660 psxi->lpVtbl->Release(psxi);
1661 pspsx->lpVtbl->Release(pspsx);
1664 else
1665 pspsx->lpVtbl->Release(pspsx);
1670 } while (psxa->uiCount != psxa->uiAllocated);
1672 else
1673 lRet = ERROR_NOT_ENOUGH_MEMORY;
1675 RegCloseKey(hkPropSheetHandlers);
1678 if (lRet != ERROR_SUCCESS && psxa)
1680 SHDestroyPropSheetExtArray((HPSXA)psxa);
1681 psxa = NULL;
1684 return (HPSXA)psxa;
1687 /*************************************************************************
1688 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1690 UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
1692 PSXA_CALL Call;
1693 UINT i;
1694 PPSXA psxa = (PPSXA)hpsxa;
1696 TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam);
1698 if (psxa)
1700 ZeroMemory(&Call, sizeof(Call));
1701 Call.lpfnAddReplaceWith = lpfnReplaceWith;
1702 Call.lParam = lParam;
1704 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1705 Each shell extension is only allowed to call the callback once during the callback. */
1706 for (i = 0; i != psxa->uiCount; i++)
1708 Call.bCalled = FALSE;
1709 psxa->pspsx[i]->lpVtbl->ReplacePage(psxa->pspsx[i], uPageID, PsxaCall, (LPARAM)&Call);
1712 return Call.uiCount;
1715 return 0;
1718 /*************************************************************************
1719 * SHDestroyPropSheetExtArray [SHELL32.169]
1721 void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
1723 UINT i;
1724 PPSXA psxa = (PPSXA)hpsxa;
1726 TRACE("(%p)\n", hpsxa);
1728 if (psxa)
1730 for (i = 0; i != psxa->uiCount; i++)
1732 psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]);
1735 LocalFree((HLOCAL)psxa);
1739 /*************************************************************************
1740 * CIDLData_CreateFromIDArray [SHELL32.83]
1742 * Create IDataObject from PIDLs??
1744 HRESULT WINAPI CIDLData_CreateFromIDArray(
1745 LPCITEMIDLIST pidlFolder,
1746 DWORD cpidlFiles,
1747 LPCITEMIDLIST *lppidlFiles,
1748 LPDATAOBJECT *ppdataObject)
1750 UINT i;
1751 HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */
1753 TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1754 if (TRACE_ON(pidl))
1756 pdump (pidlFolder);
1757 for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1759 *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1760 lppidlFiles, cpidlFiles);
1761 if (*ppdataObject) return S_OK;
1762 return E_OUTOFMEMORY;
1765 /*************************************************************************
1766 * SHCreateStdEnumFmtEtc [SHELL32.74]
1768 * NOTES
1771 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1772 DWORD cFormats,
1773 const FORMATETC *lpFormats,
1774 LPENUMFORMATETC *ppenumFormatetc)
1776 IEnumFORMATETC *pef;
1777 HRESULT hRes;
1778 TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1780 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1781 if (!pef)
1782 return E_OUTOFMEMORY;
1784 IEnumFORMATETC_AddRef(pef);
1785 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1786 IEnumFORMATETC_Release(pef);
1788 return hRes;
1792 /*************************************************************************
1793 * SHELL32_256 (SHELL32.256)
1795 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1797 HRESULT ret = S_OK;
1799 FIXME("stub %p 0x%08x %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1801 if (!lpdw0 || *lpdw0 != 0x10)
1802 ret = E_INVALIDARG;
1803 else
1805 LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1807 if (!lpdata)
1808 ret = E_OUTOFMEMORY;
1809 else
1811 /* Initialize and return unknown lpdata structure */
1815 return ret;
1818 /*************************************************************************
1819 * SHFindFiles (SHELL32.90)
1821 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1823 FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1824 return FALSE;
1827 /*************************************************************************
1828 * SHUpdateImageW (SHELL32.192)
1830 * Notifies the shell that an icon in the system image list has been changed.
1832 * PARAMS
1833 * pszHashItem [I] Path to file that contains the icon.
1834 * iIndex [I] Zero-based index of the icon in the file.
1835 * uFlags [I] Flags determining the icon attributes. See notes.
1836 * iImageIndex [I] Index of the icon in the system image list.
1838 * RETURNS
1839 * Nothing
1841 * NOTES
1842 * uFlags can be one or more of the following flags:
1843 * GIL_NOTFILENAME - pszHashItem is not a file name.
1844 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1846 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
1848 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
1851 /*************************************************************************
1852 * SHUpdateImageA (SHELL32.191)
1854 * See SHUpdateImageW.
1856 VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex)
1858 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex);
1861 INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra)
1863 FIXME("%p - stub\n", pidlExtra);
1865 return -1;
1868 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
1870 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
1872 return TRUE;
1875 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
1876 UINT uFlags)
1878 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo), debugstr_a(pszDir),
1879 pszName, pfMustCopy, uFlags);
1881 return FALSE;
1884 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
1885 UINT uFlags)
1887 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
1888 pszName, pfMustCopy, uFlags);
1890 return FALSE;
1893 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
1895 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
1897 return S_OK;
1900 HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
1902 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1904 return S_OK;
1907 HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
1909 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1911 return S_OK;
1914 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
1916 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
1918 return SHFMT_NOFORMAT;
1921 HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1923 FIXME("%s, %p - stub\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1925 pSHQueryRBInfo->i64Size = 0;
1926 pSHQueryRBInfo->i64NumItems = 0;
1928 return S_OK;
1931 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1933 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1935 pSHQueryRBInfo->i64Size = 0;
1936 pSHQueryRBInfo->i64NumItems = 0;
1938 return S_OK;
1941 /*************************************************************************
1942 * SHSetLocalizedName (SHELL32.@)
1944 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
1946 FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
1948 return S_OK;