push 43f03fe87c2254c6df67b2de3c08b5b20fd64327
[wine/hacks.git] / dlls / shell32 / shellord.c
blobeaf285977ba7377f1b6baeaed4b2c528594d352f
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"
36 #include "winternl.h"
38 #include "shellapi.h"
39 #include "objbase.h"
40 #include "shlguid.h"
41 #include "wingdi.h"
42 #include "winuser.h"
43 #include "shlobj.h"
44 #include "shell32_main.h"
45 #include "undocshell.h"
46 #include "pidl.h"
47 #include "shlwapi.h"
48 #include "commdlg.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(shell);
51 WINE_DECLARE_DEBUG_CHANNEL(pidl);
53 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
54 /* !!! it is in both here and comctl32undoc.c !!! */
55 typedef struct tagCREATEMRULIST
57 DWORD cbSize; /* size of struct */
58 DWORD nMaxItems; /* max no. of items in list */
59 DWORD dwFlags; /* see below */
60 HKEY hKey; /* root reg. key under which list is saved */
61 LPCSTR lpszSubKey; /* reg. subkey */
62 PROC lpfnCompare; /* item compare proc */
63 } CREATEMRULISTA, *LPCREATEMRULISTA;
65 /* dwFlags */
66 #define MRUF_STRING_LIST 0 /* list will contain strings */
67 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
68 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
70 extern HANDLE WINAPI CreateMRUListA(LPCREATEMRULISTA lpcml);
71 extern DWORD WINAPI FreeMRUList(HANDLE hMRUList);
72 extern INT WINAPI AddMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData);
73 extern INT WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
74 extern INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
77 /* Get a function pointer from a DLL handle */
78 #define GET_FUNC(func, module, name, fail) \
79 do { \
80 if (!func) { \
81 if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
82 func = (void*)GetProcAddress(SHELL32_h##module, name); \
83 if (!func) return fail; \
84 } \
85 } while (0)
87 /* Function pointers for GET_FUNC macro */
88 static HMODULE SHELL32_hshlwapi=NULL;
89 static HANDLE (WINAPI *pSHAllocShared)(LPCVOID,DWORD,DWORD);
90 static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD);
91 static BOOL (WINAPI *pSHUnlockShared)(LPVOID);
92 static BOOL (WINAPI *pSHFreeShared)(HANDLE,DWORD);
95 /*************************************************************************
96 * ParseFieldA [internal]
98 * copies a field from a ',' delimited string
100 * first field is nField = 1
102 DWORD WINAPI ParseFieldA(
103 LPCSTR src,
104 DWORD nField,
105 LPSTR dst,
106 DWORD len)
108 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src),nField,dst,len);
110 if (!src || !src[0] || !dst || !len)
111 return 0;
113 /* skip n fields delimited by ',' */
114 while (nField > 1)
116 if (*src=='\0') return FALSE;
117 if (*(src++)==',') nField--;
120 /* copy part till the next ',' to dst */
121 while ( *src!='\0' && *src!=',' && (len--)>0 ) *(dst++)=*(src++);
123 /* finalize the string */
124 *dst=0x0;
126 return TRUE;
129 /*************************************************************************
130 * ParseFieldW [internal]
132 * copies a field from a ',' delimited string
134 * first field is nField = 1
136 DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len)
138 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src), nField, dst, len);
140 if (!src || !src[0] || !dst || !len)
141 return 0;
143 /* skip n fields delimited by ',' */
144 while (nField > 1)
146 if (*src == 0x0) return FALSE;
147 if (*src++ == ',') nField--;
150 /* copy part till the next ',' to dst */
151 while ( *src != 0x0 && *src != ',' && (len--)>0 ) *(dst++) = *(src++);
153 /* finalize the string */
154 *dst = 0x0;
156 return TRUE;
159 /*************************************************************************
160 * ParseField [SHELL32.58]
162 DWORD WINAPI ParseFieldAW(LPCVOID src, DWORD nField, LPVOID dst, DWORD len)
164 if (SHELL_OsIsUnicode())
165 return ParseFieldW(src, nField, dst, len);
166 return ParseFieldA(src, nField, dst, len);
169 /*************************************************************************
170 * GetFileNameFromBrowse [SHELL32.63]
173 BOOL WINAPI GetFileNameFromBrowse(
174 HWND hwndOwner,
175 LPSTR lpstrFile,
176 DWORD nMaxFile,
177 LPCSTR lpstrInitialDir,
178 LPCSTR lpstrDefExt,
179 LPCSTR lpstrFilter,
180 LPCSTR lpstrTitle)
182 HMODULE hmodule;
183 FARPROC pGetOpenFileNameA;
184 OPENFILENAMEA ofn;
185 BOOL ret;
187 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
188 hwndOwner, lpstrFile, nMaxFile, lpstrInitialDir, lpstrDefExt,
189 lpstrFilter, lpstrTitle);
191 hmodule = LoadLibraryA("comdlg32.dll");
192 if(!hmodule) return FALSE;
193 pGetOpenFileNameA = GetProcAddress(hmodule, "GetOpenFileNameA");
194 if(!pGetOpenFileNameA)
196 FreeLibrary(hmodule);
197 return FALSE;
200 memset(&ofn, 0, sizeof(ofn));
202 ofn.lStructSize = sizeof(ofn);
203 ofn.hwndOwner = hwndOwner;
204 ofn.lpstrFilter = lpstrFilter;
205 ofn.lpstrFile = lpstrFile;
206 ofn.nMaxFile = nMaxFile;
207 ofn.lpstrInitialDir = lpstrInitialDir;
208 ofn.lpstrTitle = lpstrTitle;
209 ofn.lpstrDefExt = lpstrDefExt;
210 ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
211 ret = pGetOpenFileNameA(&ofn);
213 FreeLibrary(hmodule);
214 return ret;
217 /*************************************************************************
218 * SHGetSetSettings [SHELL32.68]
220 VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
222 if(bSet)
224 FIXME("%p 0x%08x TRUE\n", lpss, dwMask);
226 else
228 SHGetSettings((LPSHELLFLAGSTATE)lpss,dwMask);
232 /*************************************************************************
233 * SHGetSettings [SHELL32.@]
235 * NOTES
236 * the registry path are for win98 (tested)
237 * and possibly are the same in nt40
240 VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask)
242 HKEY hKey;
243 DWORD dwData;
244 DWORD dwDataSize = sizeof (DWORD);
246 TRACE("(%p 0x%08x)\n",lpsfs,dwMask);
248 if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
249 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0))
250 return;
252 if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize))
253 lpsfs->fShowExtensions = ((dwData == 0) ? 0 : 1);
255 if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize))
256 lpsfs->fShowInfoTip = ((dwData == 0) ? 0 : 1);
258 if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize))
259 lpsfs->fDontPrettyPath = ((dwData == 0) ? 0 : 1);
261 if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize))
262 lpsfs->fHideIcons = ((dwData == 0) ? 0 : 1);
264 if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize))
265 lpsfs->fMapNetDrvBtn = ((dwData == 0) ? 0 : 1);
267 if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize))
268 lpsfs->fShowAttribCol = ((dwData == 0) ? 0 : 1);
270 if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize))
271 { if (dwData == 0)
272 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
273 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
275 else if (dwData == 1)
276 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 1;
277 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
279 else if (dwData == 2)
280 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
281 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 1;
284 RegCloseKey (hKey);
286 TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
289 /*************************************************************************
290 * SHShellFolderView_Message [SHELL32.73]
292 * Send a message to an explorer cabinet window.
294 * PARAMS
295 * hwndCabinet [I] The window containing the shellview to communicate with
296 * dwMessage [I] The SFVM message to send
297 * dwParam [I] Message parameter
299 * RETURNS
300 * fixme.
302 * NOTES
303 * Message SFVM_REARRANGE = 1
305 * This message gets sent when a column gets clicked to instruct the
306 * shell view to re-sort the item list. dwParam identifies the column
307 * that was clicked.
309 LRESULT WINAPI SHShellFolderView_Message(
310 HWND hwndCabinet,
311 UINT uMessage,
312 LPARAM lParam)
314 FIXME("%p %08x %08lx stub\n",hwndCabinet, uMessage, lParam);
315 return 0;
318 /*************************************************************************
319 * RegisterShellHook [SHELL32.181]
321 * Register a shell hook.
323 * PARAMS
324 * hwnd [I] Window handle
325 * dwType [I] Type of hook.
327 * NOTES
328 * Exported by ordinal
330 BOOL WINAPI RegisterShellHook(
331 HWND hWnd,
332 DWORD dwType)
334 FIXME("(%p,0x%08x):stub.\n",hWnd, dwType);
335 return TRUE;
338 /*************************************************************************
339 * ShellMessageBoxW [SHELL32.182]
341 * See ShellMessageBoxA.
343 * NOTE:
344 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
345 * because we can't forward to it in the .spec file since it's exported by
346 * ordinal. If you change the implementation here please update the code in
347 * shlwapi as well.
349 int WINAPIV ShellMessageBoxW(
350 HINSTANCE hInstance,
351 HWND hWnd,
352 LPCWSTR lpText,
353 LPCWSTR lpCaption,
354 UINT uType,
355 ...)
357 WCHAR szText[100],szTitle[100];
358 LPCWSTR pszText = szText, pszTitle = szTitle;
359 LPWSTR pszTemp;
360 __ms_va_list args;
361 int ret;
363 __ms_va_start(args, uType);
364 /* wvsprintfA(buf,fmt, args); */
366 TRACE("(%p,%p,%p,%p,%08x)\n",
367 hInstance,hWnd,lpText,lpCaption,uType);
369 if (IS_INTRESOURCE(lpCaption))
370 LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
371 else
372 pszTitle = lpCaption;
374 if (IS_INTRESOURCE(lpText))
375 LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
376 else
377 pszText = lpText;
379 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
380 pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
382 __ms_va_end(args);
384 ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
385 LocalFree(pszTemp);
386 return ret;
389 /*************************************************************************
390 * ShellMessageBoxA [SHELL32.183]
392 * Format and output an error message.
394 * PARAMS
395 * hInstance [I] Instance handle of message creator
396 * hWnd [I] Window handle of message creator
397 * lpText [I] Resource Id of title or LPSTR
398 * lpCaption [I] Resource Id of title or LPSTR
399 * uType [I] Type of error message
401 * RETURNS
402 * A return value from MessageBoxA().
404 * NOTES
405 * Exported by ordinal
407 int WINAPIV ShellMessageBoxA(
408 HINSTANCE hInstance,
409 HWND hWnd,
410 LPCSTR lpText,
411 LPCSTR lpCaption,
412 UINT uType,
413 ...)
415 char szText[100],szTitle[100];
416 LPCSTR pszText = szText, pszTitle = szTitle;
417 LPSTR pszTemp;
418 __ms_va_list args;
419 int ret;
421 __ms_va_start(args, uType);
422 /* wvsprintfA(buf,fmt, args); */
424 TRACE("(%p,%p,%p,%p,%08x)\n",
425 hInstance,hWnd,lpText,lpCaption,uType);
427 if (IS_INTRESOURCE(lpCaption))
428 LoadStringA(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle));
429 else
430 pszTitle = lpCaption;
432 if (IS_INTRESOURCE(lpText))
433 LoadStringA(hInstance, LOWORD(lpText), szText, sizeof(szText));
434 else
435 pszText = lpText;
437 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
438 pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
440 __ms_va_end(args);
442 ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
443 LocalFree(pszTemp);
444 return ret;
447 /*************************************************************************
448 * SHRegisterDragDrop [SHELL32.86]
450 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
451 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
452 * for details. Under Windows 98 this function initializes the true OLE when called
453 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
455 * We follow Windows 98 behaviour.
457 * NOTES
458 * exported by ordinal
460 * SEE ALSO
461 * RegisterDragDrop, SHLoadOLE
463 HRESULT WINAPI SHRegisterDragDrop(
464 HWND hWnd,
465 LPDROPTARGET pDropTarget)
467 static BOOL ole_initialized = FALSE;
468 HRESULT hr;
470 TRACE("(%p,%p)\n", hWnd, pDropTarget);
472 if (!ole_initialized)
474 hr = OleInitialize(NULL);
475 if (FAILED(hr))
476 return hr;
477 ole_initialized = TRUE;
479 return RegisterDragDrop(hWnd, pDropTarget);
482 /*************************************************************************
483 * SHRevokeDragDrop [SHELL32.87]
485 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
486 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
487 * for details. Function removed from Windows Vista.
489 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
490 * not called.
492 * NOTES
493 * exported by ordinal
495 * SEE ALSO
496 * RevokeDragDrop, SHLoadOLE
498 HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
500 TRACE("(%p)\n", hWnd);
501 return RevokeDragDrop(hWnd);
504 /*************************************************************************
505 * SHDoDragDrop [SHELL32.88]
507 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
508 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
509 * for details
511 * NOTES
512 * exported by ordinal
514 * SEE ALSO
515 * DoDragDrop, SHLoadOLE
517 HRESULT WINAPI SHDoDragDrop(
518 HWND hWnd,
519 LPDATAOBJECT lpDataObject,
520 LPDROPSOURCE lpDropSource,
521 DWORD dwOKEffect,
522 LPDWORD pdwEffect)
524 FIXME("(%p %p %p 0x%08x %p):stub.\n",
525 hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
526 return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
529 /*************************************************************************
530 * ArrangeWindows [SHELL32.184]
533 WORD WINAPI ArrangeWindows(
534 HWND hwndParent,
535 DWORD dwReserved,
536 LPCRECT lpRect,
537 WORD cKids,
538 CONST HWND * lpKids)
540 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
541 hwndParent, dwReserved, lpRect, cKids, lpKids);
542 return 0;
545 /*************************************************************************
546 * SignalFileOpen [SHELL32.103]
548 * NOTES
549 * exported by ordinal
551 DWORD WINAPI
552 SignalFileOpen (DWORD dwParam1)
554 FIXME("(0x%08x):stub.\n", dwParam1);
556 return 0;
559 /*************************************************************************
560 * SHADD_get_policy - helper function for SHAddToRecentDocs
562 * PARAMETERS
563 * policy [IN] policy name (null termed string) to find
564 * type [OUT] ptr to DWORD to receive type
565 * buffer [OUT] ptr to area to hold data retrieved
566 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
567 * length filled
569 * RETURNS
570 * result of the SHQueryValueEx call
572 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
574 HKEY Policy_basekey;
575 INT ret;
577 /* Get the key for the policies location in the registry
579 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
580 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
581 0, KEY_READ, &Policy_basekey)) {
583 if (RegOpenKeyExA(HKEY_CURRENT_USER,
584 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
585 0, KEY_READ, &Policy_basekey)) {
586 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
587 policy);
588 *len = 0;
589 return ERROR_FILE_NOT_FOUND;
593 /* Retrieve the data if it exists
595 ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len);
596 RegCloseKey(Policy_basekey);
597 return ret;
601 /*************************************************************************
602 * SHADD_compare_mru - helper function for SHAddToRecentDocs
604 * PARAMETERS
605 * data1 [IN] data being looked for
606 * data2 [IN] data in MRU
607 * cbdata [IN] length from FindMRUData call (not used)
609 * RETURNS
610 * position within MRU list that data was added.
612 static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData)
614 return lstrcmpiA(data1, data2);
617 /*************************************************************************
618 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
620 * PARAMETERS
621 * mruhandle [IN] handle for created MRU list
622 * doc_name [IN] null termed pure doc name
623 * new_lnk_name [IN] null termed path and file name for .lnk file
624 * buffer [IN/OUT] 2048 byte area to construct MRU data
625 * len [OUT] ptr to int to receive space used in buffer
627 * RETURNS
628 * position within MRU list that data was added.
630 static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPCSTR doc_name, LPCSTR new_lnk_name,
631 LPSTR buffer, INT *len)
633 LPSTR ptr;
634 INT wlen;
636 /*FIXME: Document:
637 * RecentDocs MRU data structure seems to be:
638 * +0h document file name w/ terminating 0h
639 * +nh short int w/ size of remaining
640 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
641 * +n+4h 10 bytes zeros - unknown
642 * +n+eh shortcut file name w/ terminating 0h
643 * +n+e+nh 3 zero bytes - unknown
646 /* Create the MRU data structure for "RecentDocs"
648 ptr = buffer;
649 lstrcpyA(ptr, doc_name);
650 ptr += (lstrlenA(buffer) + 1);
651 wlen= lstrlenA(new_lnk_name) + 1 + 12;
652 *((short int*)ptr) = wlen;
653 ptr += 2; /* step past the length */
654 *(ptr++) = 0x30; /* unknown reason */
655 *(ptr++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
656 memset(ptr, 0, 10);
657 ptr += 10;
658 lstrcpyA(ptr, new_lnk_name);
659 ptr += (lstrlenA(new_lnk_name) + 1);
660 memset(ptr, 0, 3);
661 ptr += 3;
662 *len = ptr - buffer;
664 /* Add the new entry into the MRU list
666 return AddMRUData(mruhandle, buffer, *len);
669 /*************************************************************************
670 * SHAddToRecentDocs [SHELL32.@]
672 * Modify (add/clear) Shell's list of recently used documents.
674 * PARAMETERS
675 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
676 * pv [IN] string or pidl, NULL clears the list
678 * NOTES
679 * exported by name
681 * FIXME
682 * convert to unicode
684 void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
686 /* If list is a string list lpfnCompare has the following prototype
687 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
688 * for binary lists the prototype is
689 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
690 * where cbData is the no. of bytes to compare.
691 * Need to check what return value means identical - 0?
695 UINT olderrormode;
696 HKEY HCUbasekey;
697 CHAR doc_name[MAX_PATH];
698 CHAR link_dir[MAX_PATH];
699 CHAR new_lnk_filepath[MAX_PATH];
700 CHAR new_lnk_name[MAX_PATH];
701 IMalloc *ppM;
702 LPITEMIDLIST pidl;
703 HWND hwnd = 0; /* FIXME: get real window handle */
704 INT ret;
705 DWORD data[64], datalen, type;
707 TRACE("%04x %p\n", uFlags, pv);
709 /*FIXME: Document:
710 * RecentDocs MRU data structure seems to be:
711 * +0h document file name w/ terminating 0h
712 * +nh short int w/ size of remaining
713 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
714 * +n+4h 10 bytes zeros - unknown
715 * +n+eh shortcut file name w/ terminating 0h
716 * +n+e+nh 3 zero bytes - unknown
719 /* See if we need to do anything.
721 datalen = 64;
722 ret=SHADD_get_policy( "NoRecentDocsHistory", &type, data, &datalen);
723 if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) {
724 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret);
725 return;
727 if (ret == ERROR_SUCCESS) {
728 if (!( (type == REG_DWORD) ||
729 ((type == REG_BINARY) && (datalen == 4)) )) {
730 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
731 type, datalen);
732 return;
735 TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
736 /* now test the actual policy value */
737 if ( data[0] != 0)
738 return;
741 /* Open key to where the necessary info is
743 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
744 * and the close should be done during the _DETACH. The resulting
745 * key is stored in the DLL global data.
747 if (RegCreateKeyExA(HKEY_CURRENT_USER,
748 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
749 0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
750 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
751 return;
754 /* Get path to user's "Recent" directory
756 if(SUCCEEDED(SHGetMalloc(&ppM))) {
757 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
758 &pidl))) {
759 SHGetPathFromIDListA(pidl, link_dir);
760 IMalloc_Free(ppM, pidl);
762 else {
763 /* serious issues */
764 link_dir[0] = 0;
765 ERR("serious issues 1\n");
767 IMalloc_Release(ppM);
769 else {
770 /* serious issues */
771 link_dir[0] = 0;
772 ERR("serious issues 2\n");
774 TRACE("Users Recent dir %s\n", link_dir);
776 /* If no input, then go clear the lists */
777 if (!pv) {
778 /* clear user's Recent dir
781 /* FIXME: delete all files in "link_dir"
783 * while( more files ) {
784 * lstrcpyA(old_lnk_name, link_dir);
785 * PathAppendA(old_lnk_name, filenam);
786 * DeleteFileA(old_lnk_name);
789 FIXME("should delete all files in %s\\\n", link_dir);
791 /* clear MRU list
793 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
794 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
795 * and naturally it fails w/ rc=2. It should do it against
796 * HKEY_CURRENT_USER which is where it is stored, and where
797 * the MRU routines expect it!!!!
799 RegDeleteKeyA(HCUbasekey, "RecentDocs");
800 RegCloseKey(HCUbasekey);
801 return;
804 /* Have data to add, the jobs to be done:
805 * 1. Add document to MRU list in registry "HKCU\Software\
806 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
807 * 2. Add shortcut to document in the user's Recent directory
808 * (CSIDL_RECENT).
809 * 3. Add shortcut to Start menu's Documents submenu.
812 /* Get the pure document name from the input
814 switch (uFlags)
816 case SHARD_PIDL:
817 SHGetPathFromIDListA(pv, doc_name);
818 break;
820 case SHARD_PATHA:
821 lstrcpynA(doc_name, pv, MAX_PATH);
822 break;
824 case SHARD_PATHW:
825 WideCharToMultiByte(CP_ACP, 0, pv, -1, doc_name, MAX_PATH, NULL, NULL);
826 break;
828 default:
829 FIXME("Unsupported flags: %u\n", uFlags);
830 return;
833 TRACE("full document name %s\n", debugstr_a(doc_name));
834 PathStripPathA(doc_name);
835 TRACE("stripped document name %s\n", debugstr_a(doc_name));
838 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
840 { /* on input needs:
841 * doc_name - pure file-spec, no path
842 * link_dir - path to the user's Recent directory
843 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
844 * creates:
845 * new_lnk_name- pure file-spec, no path for new .lnk file
846 * new_lnk_filepath
847 * - path and file name of new .lnk file
849 CREATEMRULISTA mymru;
850 HANDLE mruhandle;
851 INT len, pos, bufused, err;
852 INT i;
853 DWORD attr;
854 CHAR buffer[2048];
855 CHAR *ptr;
856 CHAR old_lnk_name[MAX_PATH];
857 short int slen;
859 mymru.cbSize = sizeof(CREATEMRULISTA);
860 mymru.nMaxItems = 15;
861 mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE;
862 mymru.hKey = HCUbasekey;
863 mymru.lpszSubKey = "RecentDocs";
864 mymru.lpfnCompare = (PROC)SHADD_compare_mru;
865 mruhandle = CreateMRUListA(&mymru);
866 if (!mruhandle) {
867 /* MRU failed */
868 ERR("MRU processing failed, handle zero\n");
869 RegCloseKey(HCUbasekey);
870 return;
872 len = lstrlenA(doc_name);
873 pos = FindMRUData(mruhandle, doc_name, len, 0);
875 /* Now get the MRU entry that will be replaced
876 * and delete the .lnk file for it
878 if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos,
879 buffer, 2048)) != -1) {
880 ptr = buffer;
881 ptr += (lstrlenA(buffer) + 1);
882 slen = *((short int*)ptr);
883 ptr += 2; /* skip the length area */
884 if (bufused >= slen + (ptr-buffer)) {
885 /* buffer size looks good */
886 ptr += 12; /* get to string */
887 len = bufused - (ptr-buffer); /* get length of buf remaining */
888 if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
889 /* appears to be good string */
890 lstrcpyA(old_lnk_name, link_dir);
891 PathAppendA(old_lnk_name, ptr);
892 if (!DeleteFileA(old_lnk_name)) {
893 if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
894 if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
895 ERR("Delete for %s failed, err=%d, attr=%08x\n",
896 old_lnk_name, err, attr);
898 else {
899 TRACE("old .lnk file %s did not exist\n",
900 old_lnk_name);
903 else {
904 ERR("Delete for %s failed, attr=%08x\n",
905 old_lnk_name, attr);
908 else {
909 TRACE("deleted old .lnk file %s\n", old_lnk_name);
915 /* Create usable .lnk file name for the "Recent" directory
917 wsprintfA(new_lnk_name, "%s.lnk", doc_name);
918 lstrcpyA(new_lnk_filepath, link_dir);
919 PathAppendA(new_lnk_filepath, new_lnk_name);
920 i = 1;
921 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
922 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
923 i++;
924 wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
925 lstrcpyA(new_lnk_filepath, link_dir);
926 PathAppendA(new_lnk_filepath, new_lnk_name);
928 SetErrorMode(olderrormode);
929 TRACE("new shortcut will be %s\n", new_lnk_filepath);
931 /* Now add the new MRU entry and data
933 pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name,
934 buffer, &len);
935 FreeMRUList(mruhandle);
936 TRACE("Updated MRU list, new doc is position %d\n", pos);
939 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
941 { /* on input needs:
942 * doc_name - pure file-spec, no path
943 * new_lnk_filepath
944 * - path and file name of new .lnk file
945 * uFlags[in] - flags on call to SHAddToRecentDocs
946 * pv[in] - document path/pidl on call to SHAddToRecentDocs
948 IShellLinkA *psl = NULL;
949 IPersistFile *pPf = NULL;
950 HRESULT hres;
951 CHAR desc[MAX_PATH];
952 WCHAR widelink[MAX_PATH];
954 CoInitialize(0);
956 hres = CoCreateInstance( &CLSID_ShellLink,
957 NULL,
958 CLSCTX_INPROC_SERVER,
959 &IID_IShellLinkA,
960 (LPVOID )&psl);
961 if(SUCCEEDED(hres)) {
963 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
964 (LPVOID *)&pPf);
965 if(FAILED(hres)) {
966 /* bombed */
967 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
968 goto fail;
971 /* Set the document path or pidl */
972 if (uFlags == SHARD_PIDL) {
973 hres = IShellLinkA_SetIDList(psl, pv);
974 } else {
975 hres = IShellLinkA_SetPath(psl, pv);
977 if(FAILED(hres)) {
978 /* bombed */
979 ERR("failed Set{IDList|Path} %08x\n", hres);
980 goto fail;
983 lstrcpyA(desc, "Shortcut to ");
984 lstrcatA(desc, doc_name);
985 hres = IShellLinkA_SetDescription(psl, desc);
986 if(FAILED(hres)) {
987 /* bombed */
988 ERR("failed SetDescription %08x\n", hres);
989 goto fail;
992 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
993 widelink, MAX_PATH);
994 /* create the short cut */
995 hres = IPersistFile_Save(pPf, widelink, TRUE);
996 if(FAILED(hres)) {
997 /* bombed */
998 ERR("failed IPersistFile::Save %08x\n", hres);
999 IPersistFile_Release(pPf);
1000 IShellLinkA_Release(psl);
1001 goto fail;
1003 hres = IPersistFile_SaveCompleted(pPf, widelink);
1004 IPersistFile_Release(pPf);
1005 IShellLinkA_Release(psl);
1006 TRACE("shortcut %s has been created, result=%08x\n",
1007 new_lnk_filepath, hres);
1009 else {
1010 ERR("CoCreateInstance failed, hres=%08x\n", hres);
1014 fail:
1015 CoUninitialize();
1017 /* all done */
1018 RegCloseKey(HCUbasekey);
1019 return;
1022 /*************************************************************************
1023 * SHCreateShellFolderViewEx [SHELL32.174]
1025 * Create a new instance of the default Shell folder view object.
1027 * RETURNS
1028 * Success: S_OK
1029 * Failure: error value
1031 * NOTES
1032 * see IShellFolder::CreateViewObject
1034 HRESULT WINAPI SHCreateShellFolderViewEx(
1035 LPCSFV psvcbi, /* [in] shelltemplate struct */
1036 IShellView **ppv) /* [out] IShellView pointer */
1038 IShellView * psf;
1039 HRESULT hRes;
1041 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1042 psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
1043 psvcbi->fvm, psvcbi->psvOuter);
1045 psf = IShellView_Constructor(psvcbi->pshf);
1047 if (!psf)
1048 return E_OUTOFMEMORY;
1050 IShellView_AddRef(psf);
1051 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1052 IShellView_Release(psf);
1054 return hRes;
1056 /*************************************************************************
1057 * SHWinHelp [SHELL32.127]
1060 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
1061 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v,w,x,z);
1062 return 0;
1064 /*************************************************************************
1065 * SHRunControlPanel [SHELL32.161]
1068 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
1069 { FIXME("0x%08x 0x%08x stub\n",x,z);
1070 return 0;
1073 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1074 /*************************************************************************
1075 * SHSetInstanceExplorer [SHELL32.176]
1077 * NOTES
1078 * Sets the interface
1080 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1081 { TRACE("%p\n", lpUnknown);
1082 SHELL32_IExplorerInterface = lpUnknown;
1084 /*************************************************************************
1085 * SHGetInstanceExplorer [SHELL32.@]
1087 * NOTES
1088 * gets the interface pointer of the explorer and a reference
1090 HRESULT WINAPI SHGetInstanceExplorer (IUnknown **lpUnknown)
1091 { TRACE("%p\n", lpUnknown);
1093 *lpUnknown = SHELL32_IExplorerInterface;
1095 if (!SHELL32_IExplorerInterface)
1096 return E_FAIL;
1098 IUnknown_AddRef(SHELL32_IExplorerInterface);
1099 return NOERROR;
1101 /*************************************************************************
1102 * SHFreeUnusedLibraries [SHELL32.123]
1104 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1105 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1106 * for details
1108 * NOTES
1109 * exported by ordinal
1111 * SEE ALSO
1112 * CoFreeUnusedLibraries, SHLoadOLE
1114 void WINAPI SHFreeUnusedLibraries (void)
1116 FIXME("stub\n");
1117 CoFreeUnusedLibraries();
1119 /*************************************************************************
1120 * DAD_AutoScroll [SHELL32.129]
1123 BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, LPPOINT pt)
1125 FIXME("hwnd = %p %p %p\n",hwnd,samples,pt);
1126 return 0;
1128 /*************************************************************************
1129 * DAD_DragEnter [SHELL32.130]
1132 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1134 FIXME("hwnd = %p\n",hwnd);
1135 return FALSE;
1137 /*************************************************************************
1138 * DAD_DragEnterEx [SHELL32.131]
1141 BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p)
1143 FIXME("hwnd = %p (%d,%d)\n",hwnd,p.x,p.y);
1144 return FALSE;
1146 /*************************************************************************
1147 * DAD_DragMove [SHELL32.134]
1150 BOOL WINAPI DAD_DragMove(POINT p)
1152 FIXME("(%d,%d)\n",p.x,p.y);
1153 return FALSE;
1155 /*************************************************************************
1156 * DAD_DragLeave [SHELL32.132]
1159 BOOL WINAPI DAD_DragLeave(VOID)
1161 FIXME("\n");
1162 return FALSE;
1164 /*************************************************************************
1165 * DAD_SetDragImage [SHELL32.136]
1167 * NOTES
1168 * exported by name
1170 BOOL WINAPI DAD_SetDragImage(
1171 HIMAGELIST himlTrack,
1172 LPPOINT lppt)
1174 FIXME("%p %p stub\n",himlTrack, lppt);
1175 return 0;
1177 /*************************************************************************
1178 * DAD_ShowDragImage [SHELL32.137]
1180 * NOTES
1181 * exported by name
1183 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1185 FIXME("0x%08x stub\n",bShow);
1186 return 0;
1189 static const WCHAR szwCabLocation[] = {
1190 'S','o','f','t','w','a','r','e','\\',
1191 'M','i','c','r','o','s','o','f','t','\\',
1192 'W','i','n','d','o','w','s','\\',
1193 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1194 'E','x','p','l','o','r','e','r','\\',
1195 'C','a','b','i','n','e','t','S','t','a','t','e',0
1198 static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 };
1200 /*************************************************************************
1201 * ReadCabinetState [SHELL32.651] NT 4.0
1204 BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
1206 HKEY hkey = 0;
1207 DWORD type, r;
1209 TRACE("%p %d\n", cs, length);
1211 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1212 return FALSE;
1214 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1215 if( r == ERROR_SUCCESS )
1217 type = REG_BINARY;
1218 r = RegQueryValueExW( hkey, szwSettings,
1219 NULL, &type, (LPBYTE)cs, (LPDWORD)&length );
1220 RegCloseKey( hkey );
1224 /* if we can't read from the registry, create default values */
1225 if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) ||
1226 (cs->cLength != length) )
1228 ERR("Initializing shell cabinet settings\n");
1229 memset(cs, 0, sizeof(*cs));
1230 cs->cLength = sizeof(*cs);
1231 cs->nVersion = 2;
1232 cs->fFullPathTitle = FALSE;
1233 cs->fSaveLocalView = TRUE;
1234 cs->fNotShell = FALSE;
1235 cs->fSimpleDefault = TRUE;
1236 cs->fDontShowDescBar = FALSE;
1237 cs->fNewWindowMode = FALSE;
1238 cs->fShowCompColor = FALSE;
1239 cs->fDontPrettyNames = FALSE;
1240 cs->fAdminsCreateCommonGroups = TRUE;
1241 cs->fMenuEnumFilter = 96;
1244 return TRUE;
1247 /*************************************************************************
1248 * WriteCabinetState [SHELL32.652] NT 4.0
1251 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1253 DWORD r;
1254 HKEY hkey = 0;
1256 TRACE("%p\n",cs);
1258 if( cs == NULL )
1259 return FALSE;
1261 r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0,
1262 NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
1263 if( r == ERROR_SUCCESS )
1265 r = RegSetValueExW( hkey, szwSettings, 0,
1266 REG_BINARY, (LPBYTE) cs, cs->cLength);
1268 RegCloseKey( hkey );
1271 return (r==ERROR_SUCCESS);
1274 /*************************************************************************
1275 * FileIconInit [SHELL32.660]
1278 BOOL WINAPI FileIconInit(BOOL bFullInit)
1279 { FIXME("(%s)\n", bFullInit ? "true" : "false");
1280 return 0;
1282 /*************************************************************************
1283 * IsUserAdmin [SHELL32.680] NT 4.0
1286 HRESULT WINAPI IsUserAdmin(void)
1287 { FIXME("stub\n");
1288 return TRUE;
1291 /*************************************************************************
1292 * SHAllocShared [SHELL32.520]
1294 * See shlwapi.SHAllocShared
1296 HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
1298 GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
1299 return pSHAllocShared(lpvData, dwSize, dwProcId);
1302 /*************************************************************************
1303 * SHLockShared [SHELL32.521]
1305 * See shlwapi.SHLockShared
1307 LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
1309 GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
1310 return pSHLockShared(hShared, dwProcId);
1313 /*************************************************************************
1314 * SHUnlockShared [SHELL32.522]
1316 * See shlwapi.SHUnlockShared
1318 BOOL WINAPI SHUnlockShared(LPVOID lpView)
1320 GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
1321 return pSHUnlockShared(lpView);
1324 /*************************************************************************
1325 * SHFreeShared [SHELL32.523]
1327 * See shlwapi.SHFreeShared
1329 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
1331 GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
1332 return pSHFreeShared(hShared, dwProcId);
1335 /*************************************************************************
1336 * SetAppStartingCursor [SHELL32.99]
1338 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1339 { FIXME("hwnd=%p 0x%04x stub\n",u,v );
1340 return 0;
1343 /*************************************************************************
1344 * SHLoadOLE [SHELL32.151]
1346 * To reduce the memory usage of Windows 95, its shell32 contained an
1347 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1348 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1349 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1350 * would just call the Co* functions.
1352 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1353 * information from the shell32 "mini-COM" to ole32.dll.
1355 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1356 * detailed description.
1358 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1359 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1360 * hack in SHCoCreateInstance)
1362 HRESULT WINAPI SHLoadOLE(LPARAM lParam)
1363 { FIXME("0x%08lx stub\n",lParam);
1364 return S_OK;
1366 /*************************************************************************
1367 * DriveType [SHELL32.64]
1370 HRESULT WINAPI DriveType(DWORD u)
1371 { FIXME("0x%04x stub\n",u);
1372 return 0;
1374 /*************************************************************************
1375 * InvalidateDriveType [SHELL32.65]
1378 int WINAPI InvalidateDriveType(int u)
1379 { FIXME("0x%08x stub\n",u);
1380 return 0;
1382 /*************************************************************************
1383 * SHAbortInvokeCommand [SHELL32.198]
1386 HRESULT WINAPI SHAbortInvokeCommand(void)
1387 { FIXME("stub\n");
1388 return 1;
1390 /*************************************************************************
1391 * SHOutOfMemoryMessageBox [SHELL32.126]
1394 int WINAPI SHOutOfMemoryMessageBox(
1395 HWND hwndOwner,
1396 LPCSTR lpCaption,
1397 UINT uType)
1399 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1400 return 0;
1402 /*************************************************************************
1403 * SHFlushClipboard [SHELL32.121]
1406 HRESULT WINAPI SHFlushClipboard(void)
1407 { FIXME("stub\n");
1408 return 1;
1411 /*************************************************************************
1412 * SHWaitForFileToOpen [SHELL32.97]
1415 BOOL WINAPI SHWaitForFileToOpen(
1416 LPCITEMIDLIST pidl,
1417 DWORD dwFlags,
1418 DWORD dwTimeout)
1420 FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1421 return 0;
1424 /************************************************************************
1425 * @ [SHELL32.654]
1427 * NOTES
1428 * first parameter seems to be a pointer (same as passed to WriteCabinetState)
1429 * second one could be a size (0x0c). The size is the same as the structure saved to
1430 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1431 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1433 HRESULT WINAPI shell32_654 (CABINETSTATE *cs, int length)
1435 TRACE("%p %d\n",cs,length);
1436 return ReadCabinetState(cs,length);
1439 /************************************************************************
1440 * RLBuildListOfPaths [SHELL32.146]
1442 * NOTES
1443 * builds a DPA
1445 DWORD WINAPI RLBuildListOfPaths (void)
1446 { FIXME("stub\n");
1447 return 0;
1449 /************************************************************************
1450 * SHValidateUNC [SHELL32.173]
1453 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1455 FIXME("0x%08x 0x%08x 0x%08x stub\n",x,y,z);
1456 return 0;
1459 /************************************************************************
1460 * DoEnvironmentSubstA [SHELL32.@]
1462 * Replace %KEYWORD% in the str with the value of variable KEYWORD
1463 * from environment. If it is not found the %KEYWORD% is left
1464 * intact. If the buffer is too small, str is not modified.
1466 * PARAMS
1467 * pszString [I] '\0' terminated string with %keyword%.
1468 * [O] '\0' terminated string with %keyword% substituted.
1469 * cchString [I] size of str.
1471 * RETURNS
1472 * cchString length in the HIWORD;
1473 * TRUE in LOWORD if subst was successful and FALSE in other case
1475 DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
1477 LPSTR dst;
1478 BOOL res = FALSE;
1479 FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
1480 if (pszString == NULL) /* Really return 0? */
1481 return 0;
1482 if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
1484 DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
1485 if (num && num < cchString) /* dest buffer is too small */
1487 res = TRUE;
1488 memcpy(pszString, dst, num);
1490 HeapFree(GetProcessHeap(), 0, dst);
1492 return MAKELONG(res,cchString); /* Always cchString? */
1495 /************************************************************************
1496 * DoEnvironmentSubstW [SHELL32.@]
1498 * See DoEnvironmentSubstA.
1500 DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
1502 FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
1503 return MAKELONG(FALSE,cchString);
1506 /************************************************************************
1507 * DoEnvironmentSubst [SHELL32.53]
1509 * See DoEnvironmentSubstA.
1511 DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y)
1513 if (SHELL_OsIsUnicode())
1514 return DoEnvironmentSubstW(x, y);
1515 return DoEnvironmentSubstA(x, y);
1518 /*************************************************************************
1519 * @ [SHELL32.243]
1521 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1522 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1526 BOOL WINAPI shell32_243(DWORD a, DWORD b)
1528 return FALSE;
1531 /*************************************************************************
1532 * GUIDFromStringW [SHELL32.704]
1534 BOOL WINAPI GUIDFromStringW(LPCWSTR str, LPGUID guid)
1536 UNICODE_STRING guid_str;
1538 RtlInitUnicodeString(&guid_str, str);
1539 return !RtlGUIDFromString(&guid_str, guid);
1542 /*************************************************************************
1543 * @ [SHELL32.714]
1545 DWORD WINAPI SHELL32_714(LPVOID x)
1547 FIXME("(%s)stub\n", debugstr_w(x));
1548 return 0;
1551 typedef struct _PSXA
1553 UINT uiCount;
1554 UINT uiAllocated;
1555 IShellPropSheetExt *pspsx[1];
1556 } PSXA, *PPSXA;
1558 typedef struct _PSXA_CALL
1560 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith;
1561 LPARAM lParam;
1562 BOOL bCalled;
1563 BOOL bMultiple;
1564 UINT uiCount;
1565 } PSXA_CALL, *PPSXA_CALL;
1567 static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam)
1569 PPSXA_CALL Call = (PPSXA_CALL)lParam;
1571 if (Call != NULL)
1573 if ((Call->bMultiple || !Call->bCalled) &&
1574 Call->lpfnAddReplaceWith(hpage, Call->lParam))
1576 Call->bCalled = TRUE;
1577 Call->uiCount++;
1578 return TRUE;
1582 return FALSE;
1585 /*************************************************************************
1586 * SHAddFromPropSheetExtArray [SHELL32.167]
1588 UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
1590 PSXA_CALL Call;
1591 UINT i;
1592 PPSXA psxa = (PPSXA)hpsxa;
1594 TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam);
1596 if (psxa)
1598 ZeroMemory(&Call, sizeof(Call));
1599 Call.lpfnAddReplaceWith = lpfnAddPage;
1600 Call.lParam = lParam;
1601 Call.bMultiple = TRUE;
1603 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1604 for (i = 0; i != psxa->uiCount; i++)
1606 psxa->pspsx[i]->lpVtbl->AddPages(psxa->pspsx[i], PsxaCall, (LPARAM)&Call);
1609 return Call.uiCount;
1612 return 0;
1615 /*************************************************************************
1616 * SHCreatePropSheetExtArray [SHELL32.168]
1618 HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
1620 return SHCreatePropSheetExtArrayEx(hKey, pszSubKey, max_iface, NULL);
1623 /*************************************************************************
1624 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1626 HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, LPDATAOBJECT pDataObj)
1628 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};
1629 WCHAR szHandler[64];
1630 DWORD dwHandlerLen;
1631 WCHAR szClsidHandler[39];
1632 DWORD dwClsidSize;
1633 CLSID clsid;
1634 LONG lRet;
1635 DWORD dwIndex;
1636 IShellExtInit *psxi;
1637 IShellPropSheetExt *pspsx;
1638 HKEY hkBase, hkPropSheetHandlers;
1639 PPSXA psxa = NULL;
1641 TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface);
1643 if (max_iface == 0)
1644 return NULL;
1646 /* Open the registry key */
1647 lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase);
1648 if (lRet != ERROR_SUCCESS)
1649 return NULL;
1651 lRet = RegOpenKeyExW(hkBase, szPropSheetSubKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkPropSheetHandlers);
1652 RegCloseKey(hkBase);
1653 if (lRet == ERROR_SUCCESS)
1655 /* Create and initialize the Property Sheet Extensions Array */
1656 psxa = LocalAlloc(LMEM_FIXED, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1657 if (psxa)
1659 ZeroMemory(psxa, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1660 psxa->uiAllocated = max_iface;
1662 /* Enumerate all subkeys and attempt to load the shell extensions */
1663 dwIndex = 0;
1666 dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]);
1667 lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL);
1668 if (lRet != ERROR_SUCCESS)
1670 if (lRet == ERROR_MORE_DATA)
1671 continue;
1673 if (lRet == ERROR_NO_MORE_ITEMS)
1674 lRet = ERROR_SUCCESS;
1675 break;
1678 dwClsidSize = sizeof(szClsidHandler);
1679 if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
1681 /* Force a NULL-termination and convert the string */
1682 szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
1683 if (SUCCEEDED(SHCLSIDFromStringW(szClsidHandler, &clsid)))
1685 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1686 Only if both interfaces are supported it's a real shell extension.
1687 Then call IShellExtInit's Initialize method. */
1688 if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx)))
1690 if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi)))
1692 if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey)))
1694 /* Add the IShellPropSheetExt instance to the array */
1695 psxa->pspsx[psxa->uiCount++] = pspsx;
1697 else
1699 psxi->lpVtbl->Release(psxi);
1700 pspsx->lpVtbl->Release(pspsx);
1703 else
1704 pspsx->lpVtbl->Release(pspsx);
1709 } while (psxa->uiCount != psxa->uiAllocated);
1711 else
1712 lRet = ERROR_NOT_ENOUGH_MEMORY;
1714 RegCloseKey(hkPropSheetHandlers);
1717 if (lRet != ERROR_SUCCESS && psxa)
1719 SHDestroyPropSheetExtArray((HPSXA)psxa);
1720 psxa = NULL;
1723 return (HPSXA)psxa;
1726 /*************************************************************************
1727 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1729 UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
1731 PSXA_CALL Call;
1732 UINT i;
1733 PPSXA psxa = (PPSXA)hpsxa;
1735 TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam);
1737 if (psxa)
1739 ZeroMemory(&Call, sizeof(Call));
1740 Call.lpfnAddReplaceWith = lpfnReplaceWith;
1741 Call.lParam = lParam;
1743 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1744 Each shell extension is only allowed to call the callback once during the callback. */
1745 for (i = 0; i != psxa->uiCount; i++)
1747 Call.bCalled = FALSE;
1748 psxa->pspsx[i]->lpVtbl->ReplacePage(psxa->pspsx[i], uPageID, PsxaCall, (LPARAM)&Call);
1751 return Call.uiCount;
1754 return 0;
1757 /*************************************************************************
1758 * SHDestroyPropSheetExtArray [SHELL32.169]
1760 void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
1762 UINT i;
1763 PPSXA psxa = (PPSXA)hpsxa;
1765 TRACE("(%p)\n", hpsxa);
1767 if (psxa)
1769 for (i = 0; i != psxa->uiCount; i++)
1771 psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]);
1774 LocalFree(psxa);
1778 /*************************************************************************
1779 * CIDLData_CreateFromIDArray [SHELL32.83]
1781 * Create IDataObject from PIDLs??
1783 HRESULT WINAPI CIDLData_CreateFromIDArray(
1784 LPCITEMIDLIST pidlFolder,
1785 DWORD cpidlFiles,
1786 LPCITEMIDLIST *lppidlFiles,
1787 LPDATAOBJECT *ppdataObject)
1789 UINT i;
1790 HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */
1792 TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1793 if (TRACE_ON(pidl))
1795 pdump (pidlFolder);
1796 for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1798 *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1799 lppidlFiles, cpidlFiles);
1800 if (*ppdataObject) return S_OK;
1801 return E_OUTOFMEMORY;
1804 /*************************************************************************
1805 * SHCreateStdEnumFmtEtc [SHELL32.74]
1807 * NOTES
1810 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1811 DWORD cFormats,
1812 const FORMATETC *lpFormats,
1813 LPENUMFORMATETC *ppenumFormatetc)
1815 IEnumFORMATETC *pef;
1816 HRESULT hRes;
1817 TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1819 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1820 if (!pef)
1821 return E_OUTOFMEMORY;
1823 IEnumFORMATETC_AddRef(pef);
1824 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1825 IEnumFORMATETC_Release(pef);
1827 return hRes;
1831 /*************************************************************************
1832 * SHELL32_256 (SHELL32.256)
1834 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1836 HRESULT ret = S_OK;
1838 FIXME("stub %p 0x%08x %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1840 if (!lpdw0 || *lpdw0 != 0x10)
1841 ret = E_INVALIDARG;
1842 else
1844 LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1846 if (!lpdata)
1847 ret = E_OUTOFMEMORY;
1848 else
1850 /* Initialize and return unknown lpdata structure */
1854 return ret;
1857 /*************************************************************************
1858 * SHFindFiles (SHELL32.90)
1860 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1862 FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1863 return FALSE;
1866 /*************************************************************************
1867 * SHUpdateImageW (SHELL32.192)
1869 * Notifies the shell that an icon in the system image list has been changed.
1871 * PARAMS
1872 * pszHashItem [I] Path to file that contains the icon.
1873 * iIndex [I] Zero-based index of the icon in the file.
1874 * uFlags [I] Flags determining the icon attributes. See notes.
1875 * iImageIndex [I] Index of the icon in the system image list.
1877 * RETURNS
1878 * Nothing
1880 * NOTES
1881 * uFlags can be one or more of the following flags:
1882 * GIL_NOTFILENAME - pszHashItem is not a file name.
1883 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1885 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
1887 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
1890 /*************************************************************************
1891 * SHUpdateImageA (SHELL32.191)
1893 * See SHUpdateImageW.
1895 VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex)
1897 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex);
1900 INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra)
1902 FIXME("%p - stub\n", pidlExtra);
1904 return -1;
1907 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
1909 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
1911 return TRUE;
1914 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
1915 UINT uFlags)
1917 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo), debugstr_a(pszDir),
1918 pszName, pfMustCopy, uFlags);
1920 return FALSE;
1923 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
1924 UINT uFlags)
1926 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
1927 pszName, pfMustCopy, uFlags);
1929 return FALSE;
1932 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
1934 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
1936 return S_OK;
1939 HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
1941 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1943 return S_OK;
1946 HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
1948 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1950 return S_OK;
1953 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
1955 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
1957 return SHFMT_NOFORMAT;
1960 HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1962 FIXME("%s, %p - stub\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1964 pSHQueryRBInfo->i64Size = 0;
1965 pSHQueryRBInfo->i64NumItems = 0;
1967 return S_OK;
1970 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1972 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1974 pSHQueryRBInfo->i64Size = 0;
1975 pSHQueryRBInfo->i64NumItems = 0;
1977 return S_OK;
1980 /*************************************************************************
1981 * SHSetLocalizedName (SHELL32.@)
1983 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
1985 FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
1987 return S_OK;
1990 /*************************************************************************
1991 * LinkWindow_RegisterClass (SHELL32.258)
1993 BOOL WINAPI LinkWindow_RegisterClass(void)
1995 FIXME("()\n");
1996 return TRUE;
1999 /*************************************************************************
2000 * LinkWindow_UnregisterClass (SHELL32.259)
2002 BOOL WINAPI LinkWindow_UnregisterClass(void)
2004 FIXME("()\n");
2005 return TRUE;
2008 /*************************************************************************
2009 * SHFlushSFCache (SHELL32.526)
2011 * Notifies the shell that a user-specified special folder location has changed.
2013 * NOTES
2014 * In Wine, the shell folder registry values are not cached, so this function
2015 * has no effect.
2017 void WINAPI SHFlushSFCache(void)
2021 HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv)
2023 FIXME("STUB: %i %s\n",iImageList,debugstr_guid(riid));
2024 return E_NOINTERFACE;