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
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
34 #include "wine/debug.h"
44 #include "shell32_main.h"
45 #include "undocshell.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;
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) \
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; \
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(
108 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src),nField,dst,len);
110 if (!src || !src[0] || !dst || !len)
113 /* skip n fields delimited by ',' */
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 */
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)
143 /* skip n fields delimited by ',' */
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 */
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(
177 LPCSTR lpstrInitialDir,
183 FARPROC pGetOpenFileNameA;
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);
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);
217 /*************************************************************************
218 * SHGetSetSettings [SHELL32.68]
220 VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
224 FIXME("%p 0x%08x TRUE\n", lpss, dwMask);
228 SHGetSettings((LPSHELLFLAGSTATE)lpss,dwMask);
232 /*************************************************************************
233 * SHGetSettings [SHELL32.@]
236 * the registry path are for win98 (tested)
237 * and possibly are the same in nt40
240 VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask)
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))
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))
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;
286 TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
289 /*************************************************************************
290 * SHShellFolderView_Message [SHELL32.73]
292 * Send a message to an explorer cabinet window.
295 * hwndCabinet [I] The window containing the shellview to communicate with
296 * dwMessage [I] The SFVM message to send
297 * dwParam [I] Message parameter
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
309 LRESULT WINAPI SHShellFolderView_Message(
314 FIXME("%p %08x %08lx stub\n",hwndCabinet, uMessage, lParam);
318 /*************************************************************************
319 * RegisterShellHook [SHELL32.181]
321 * Register a shell hook.
324 * hwnd [I] Window handle
325 * dwType [I] Type of hook.
328 * Exported by ordinal
330 BOOL WINAPI RegisterShellHook(
334 FIXME("(%p,0x%08x):stub.\n",hWnd, dwType);
338 /*************************************************************************
339 * ShellMessageBoxW [SHELL32.182]
341 * See ShellMessageBoxA.
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
349 int WINAPIV ShellMessageBoxW(
357 WCHAR szText[100],szTitle[100];
358 LPCWSTR pszText = szText, pszTitle = szTitle;
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]));
372 pszTitle = lpCaption;
374 if (IS_INTRESOURCE(lpText))
375 LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
379 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
380 pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
384 ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
389 /*************************************************************************
390 * ShellMessageBoxA [SHELL32.183]
392 * Format and output an error message.
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
402 * A return value from MessageBoxA().
405 * Exported by ordinal
407 int WINAPIV ShellMessageBoxA(
415 char szText[100],szTitle[100];
416 LPCSTR pszText = szText, pszTitle = szTitle;
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));
430 pszTitle = lpCaption;
432 if (IS_INTRESOURCE(lpText))
433 LoadStringA(hInstance, LOWORD(lpText), szText, sizeof(szText));
437 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
438 pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
442 ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
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.
458 * exported by ordinal
461 * RegisterDragDrop, SHLoadOLE
463 HRESULT WINAPI SHRegisterDragDrop(
465 LPDROPTARGET pDropTarget)
467 static BOOL ole_initialized = FALSE;
470 TRACE("(%p,%p)\n", hWnd, pDropTarget);
472 if (!ole_initialized)
474 hr = OleInitialize(NULL);
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
493 * exported by ordinal
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
512 * exported by ordinal
515 * DoDragDrop, SHLoadOLE
517 HRESULT WINAPI SHDoDragDrop(
519 LPDATAOBJECT lpDataObject,
520 LPDROPSOURCE lpDropSource,
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(
540 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
541 hwndParent, dwReserved, lpRect, cKids, lpKids);
545 /*************************************************************************
546 * SignalFileOpen [SHELL32.103]
549 * exported by ordinal
552 SignalFileOpen (DWORD dwParam1)
554 FIXME("(0x%08x):stub.\n", dwParam1);
559 /*************************************************************************
560 * SHADD_get_policy - helper function for SHAddToRecentDocs
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
570 * result of the SHQueryValueEx call
572 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
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",
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);
601 /*************************************************************************
602 * SHADD_compare_mru - helper function for SHAddToRecentDocs
605 * data1 [IN] data being looked for
606 * data2 [IN] data in MRU
607 * cbdata [IN] length from FindMRUData call (not used)
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
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
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)
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"
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 */
658 lstrcpyA(ptr, new_lnk_name);
659 ptr += (lstrlenA(new_lnk_name) + 1);
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.
675 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
676 * pv [IN] string or pidl, NULL clears the list
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?
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];
703 HWND hwnd = 0; /* FIXME: get real window handle */
705 DWORD data[64], datalen, type;
707 TRACE("%04x %p\n", uFlags, pv);
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.
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);
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",
735 TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
736 /* now test the actual policy value */
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");
754 /* Get path to user's "Recent" directory
756 if(SUCCEEDED(SHGetMalloc(&ppM))) {
757 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
759 SHGetPathFromIDListA(pidl, link_dir);
760 IMalloc_Free(ppM, pidl);
765 ERR("serious issues 1\n");
767 IMalloc_Release(ppM);
772 ERR("serious issues 2\n");
774 TRACE("Users Recent dir %s\n", link_dir);
776 /* If no input, then go clear the lists */
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);
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);
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
809 * 3. Add shortcut to Start menu's Documents submenu.
812 /* Get the pure document name from the input
817 SHGetPathFromIDListA(pv, doc_name);
821 lstrcpynA(doc_name, pv, MAX_PATH);
825 WideCharToMultiByte(CP_ACP, 0, pv, -1, doc_name, MAX_PATH, NULL, NULL);
829 FIXME("Unsupported flags: %u\n", uFlags);
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 *** */
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
845 * new_lnk_name- pure file-spec, no path for new .lnk file
847 * - path and file name of new .lnk file
849 CREATEMRULISTA mymru;
851 INT len, pos, bufused, err;
856 CHAR old_lnk_name[MAX_PATH];
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);
868 ERR("MRU processing failed, handle zero\n");
869 RegCloseKey(HCUbasekey);
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) {
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);
899 TRACE("old .lnk file %s did not exist\n",
904 ERR("Delete for %s failed, attr=%08x\n",
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);
921 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
922 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
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,
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 *** */
942 * doc_name - pure file-spec, no path
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;
952 WCHAR widelink[MAX_PATH];
956 hres = CoCreateInstance( &CLSID_ShellLink,
958 CLSCTX_INPROC_SERVER,
961 if(SUCCEEDED(hres)) {
963 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
967 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
971 /* Set the document path or pidl */
972 if (uFlags == SHARD_PIDL) {
973 hres = IShellLinkA_SetIDList(psl, pv);
975 hres = IShellLinkA_SetPath(psl, pv);
979 ERR("failed Set{IDList|Path} %08x\n", hres);
983 lstrcpyA(desc, "Shortcut to ");
984 lstrcatA(desc, doc_name);
985 hres = IShellLinkA_SetDescription(psl, desc);
988 ERR("failed SetDescription %08x\n", hres);
992 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
994 /* create the short cut */
995 hres = IPersistFile_Save(pPf, widelink, TRUE);
998 ERR("failed IPersistFile::Save %08x\n", hres);
999 IPersistFile_Release(pPf);
1000 IShellLinkA_Release(psl);
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);
1010 ERR("CoCreateInstance failed, hres=%08x\n", hres);
1018 RegCloseKey(HCUbasekey);
1022 /*************************************************************************
1023 * SHCreateShellFolderViewEx [SHELL32.174]
1025 * Create a new instance of the default Shell folder view object.
1029 * Failure: error value
1032 * see IShellFolder::CreateViewObject
1034 HRESULT WINAPI SHCreateShellFolderViewEx(
1035 LPCSFV psvcbi, /* [in] shelltemplate struct */
1036 IShellView **ppv) /* [out] IShellView pointer */
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);
1048 return E_OUTOFMEMORY;
1050 IShellView_AddRef(psf);
1051 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1052 IShellView_Release(psf);
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);
1064 /*************************************************************************
1065 * SHRunControlPanel [SHELL32.161]
1068 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
1069 { FIXME("0x%08x 0x%08x stub\n",x,z);
1073 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1074 /*************************************************************************
1075 * SHSetInstanceExplorer [SHELL32.176]
1078 * Sets the interface
1080 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1081 { TRACE("%p\n", lpUnknown);
1082 SHELL32_IExplorerInterface = lpUnknown;
1084 /*************************************************************************
1085 * SHGetInstanceExplorer [SHELL32.@]
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)
1098 IUnknown_AddRef(SHELL32_IExplorerInterface);
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
1109 * exported by ordinal
1112 * CoFreeUnusedLibraries, SHLoadOLE
1114 void WINAPI SHFreeUnusedLibraries (void)
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);
1128 /*************************************************************************
1129 * DAD_DragEnter [SHELL32.130]
1132 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1134 FIXME("hwnd = %p\n",hwnd);
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);
1146 /*************************************************************************
1147 * DAD_DragMove [SHELL32.134]
1150 BOOL WINAPI DAD_DragMove(POINT p)
1152 FIXME("(%d,%d)\n",p.x,p.y);
1155 /*************************************************************************
1156 * DAD_DragLeave [SHELL32.132]
1159 BOOL WINAPI DAD_DragLeave(VOID)
1164 /*************************************************************************
1165 * DAD_SetDragImage [SHELL32.136]
1170 BOOL WINAPI DAD_SetDragImage(
1171 HIMAGELIST himlTrack,
1174 FIXME("%p %p stub\n",himlTrack, lppt);
1177 /*************************************************************************
1178 * DAD_ShowDragImage [SHELL32.137]
1183 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1185 FIXME("0x%08x stub\n",bShow);
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)
1209 TRACE("%p %d\n", cs, length);
1211 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1214 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1215 if( r == ERROR_SUCCESS )
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);
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;
1247 /*************************************************************************
1248 * WriteCabinetState [SHELL32.652] NT 4.0
1251 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
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");
1282 /*************************************************************************
1283 * IsUserAdmin [SHELL32.680] NT 4.0
1286 HRESULT WINAPI IsUserAdmin(void)
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 );
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);
1366 /*************************************************************************
1367 * DriveType [SHELL32.64]
1370 HRESULT WINAPI DriveType(DWORD u)
1371 { FIXME("0x%04x stub\n",u);
1374 /*************************************************************************
1375 * InvalidateDriveType [SHELL32.65]
1378 int WINAPI InvalidateDriveType(int u)
1379 { FIXME("0x%08x stub\n",u);
1382 /*************************************************************************
1383 * SHAbortInvokeCommand [SHELL32.198]
1386 HRESULT WINAPI SHAbortInvokeCommand(void)
1390 /*************************************************************************
1391 * SHOutOfMemoryMessageBox [SHELL32.126]
1394 int WINAPI SHOutOfMemoryMessageBox(
1399 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1402 /*************************************************************************
1403 * SHFlushClipboard [SHELL32.121]
1406 HRESULT WINAPI SHFlushClipboard(void)
1411 /*************************************************************************
1412 * SHWaitForFileToOpen [SHELL32.97]
1415 BOOL WINAPI SHWaitForFileToOpen(
1420 FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1424 /************************************************************************
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]
1445 DWORD WINAPI RLBuildListOfPaths (void)
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);
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.
1467 * pszString [I] '\0' terminated string with %keyword%.
1468 * [O] '\0' terminated string with %keyword% substituted.
1469 * cchString [I] size of str.
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)
1479 FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
1480 if (pszString == NULL) /* Really 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 */
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 /*************************************************************************
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)
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 /*************************************************************************
1545 DWORD WINAPI SHELL32_714(LPVOID x)
1547 FIXME("(%s)stub\n", debugstr_w(x));
1551 typedef struct _PSXA
1555 IShellPropSheetExt *pspsx[1];
1558 typedef struct _PSXA_CALL
1560 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith;
1565 } PSXA_CALL, *PPSXA_CALL;
1567 static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam)
1569 PPSXA_CALL Call = (PPSXA_CALL)lParam;
1573 if ((Call->bMultiple || !Call->bCalled) &&
1574 Call->lpfnAddReplaceWith(hpage, Call->lParam))
1576 Call->bCalled = TRUE;
1585 /*************************************************************************
1586 * SHAddFromPropSheetExtArray [SHELL32.167]
1588 UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
1592 PPSXA psxa = (PPSXA)hpsxa;
1594 TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam);
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;
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];
1631 WCHAR szClsidHandler[39];
1636 IShellExtInit *psxi;
1637 IShellPropSheetExt *pspsx;
1638 HKEY hkBase, hkPropSheetHandlers;
1641 TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface);
1646 /* Open the registry key */
1647 lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase);
1648 if (lRet != ERROR_SUCCESS)
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]));
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 */
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)
1673 if (lRet == ERROR_NO_MORE_ITEMS)
1674 lRet = ERROR_SUCCESS;
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;
1699 psxi->lpVtbl->Release(psxi);
1700 pspsx->lpVtbl->Release(pspsx);
1704 pspsx->lpVtbl->Release(pspsx);
1709 } while (psxa->uiCount != psxa->uiAllocated);
1712 lRet = ERROR_NOT_ENOUGH_MEMORY;
1714 RegCloseKey(hkPropSheetHandlers);
1717 if (lRet != ERROR_SUCCESS && psxa)
1719 SHDestroyPropSheetExtArray((HPSXA)psxa);
1726 /*************************************************************************
1727 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1729 UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
1733 PPSXA psxa = (PPSXA)hpsxa;
1735 TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam);
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;
1757 /*************************************************************************
1758 * SHDestroyPropSheetExtArray [SHELL32.169]
1760 void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
1763 PPSXA psxa = (PPSXA)hpsxa;
1765 TRACE("(%p)\n", hpsxa);
1769 for (i = 0; i != psxa->uiCount; i++)
1771 psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]);
1778 /*************************************************************************
1779 * CIDLData_CreateFromIDArray [SHELL32.83]
1781 * Create IDataObject from PIDLs??
1783 HRESULT WINAPI CIDLData_CreateFromIDArray(
1784 LPCITEMIDLIST pidlFolder,
1786 LPCITEMIDLIST *lppidlFiles,
1787 LPDATAOBJECT *ppdataObject)
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);
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]
1810 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1812 const FORMATETC *lpFormats,
1813 LPENUMFORMATETC *ppenumFormatetc)
1815 IEnumFORMATETC *pef;
1817 TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1819 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1821 return E_OUTOFMEMORY;
1823 IEnumFORMATETC_AddRef(pef);
1824 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1825 IEnumFORMATETC_Release(pef);
1831 /*************************************************************************
1832 * SHELL32_256 (SHELL32.256)
1834 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1838 FIXME("stub %p 0x%08x %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1840 if (!lpdw0 || *lpdw0 != 0x10)
1844 LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1847 ret = E_OUTOFMEMORY;
1850 /* Initialize and return unknown lpdata structure */
1857 /*************************************************************************
1858 * SHFindFiles (SHELL32.90)
1860 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1862 FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1866 /*************************************************************************
1867 * SHUpdateImageW (SHELL32.192)
1869 * Notifies the shell that an icon in the system image list has been changed.
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.
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);
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));
1914 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
1917 WCHAR wszLinkTo[MAX_PATH];
1918 WCHAR wszDir[MAX_PATH];
1919 WCHAR wszName[MAX_PATH];
1922 MultiByteToWideChar(CP_ACP, 0, pszLinkTo, -1, wszLinkTo, MAX_PATH);
1923 MultiByteToWideChar(CP_ACP, 0, pszDir, -1, wszDir, MAX_PATH);
1925 res = SHGetNewLinkInfoW(wszLinkTo, wszDir, wszName, pfMustCopy, uFlags);
1928 WideCharToMultiByte(CP_ACP, 0, wszName, -1, pszName, MAX_PATH, NULL, NULL);
1933 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
1936 const WCHAR *basename;
1937 WCHAR *dst_basename;
1939 static const WCHAR lnkformat[] = {'%','s','.','l','n','k',0};
1940 static const WCHAR lnkformatnum[] = {'%','s',' ','(','%','d',')','.','l','n','k',0};
1942 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
1943 pszName, pfMustCopy, uFlags);
1945 *pfMustCopy = FALSE;
1947 if (uFlags & SHGNLI_PIDL)
1949 FIXME("SHGNLI_PIDL flag unsupported\n");
1954 FIXME("ignoring flags: 0x%08x\n", uFlags);
1956 /* FIXME: should test if the file is a shortcut or DOS program */
1957 if (GetFileAttributesW(pszLinkTo) == INVALID_FILE_ATTRIBUTES)
1960 basename = strrchrW(pszLinkTo, '\\');
1962 basename = basename+1;
1964 basename = pszLinkTo;
1966 lstrcpynW(pszName, pszDir, MAX_PATH);
1967 if (!PathAddBackslashW(pszName))
1970 dst_basename = pszName + strlenW(pszName);
1972 snprintfW(dst_basename, pszName + MAX_PATH - dst_basename, lnkformat, basename);
1974 while (GetFileAttributesW(pszName) != INVALID_FILE_ATTRIBUTES)
1976 snprintfW(dst_basename, pszName + MAX_PATH - dst_basename, lnkformatnum, basename, i);
1983 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
1985 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
1990 HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
1992 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1997 HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
1999 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_w(pszRootPath), dwFlags);
2004 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
2006 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
2008 return SHFMT_NOFORMAT;
2011 HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
2013 FIXME("%s, %p - stub\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
2015 pSHQueryRBInfo->i64Size = 0;
2016 pSHQueryRBInfo->i64NumItems = 0;
2021 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
2023 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
2025 pSHQueryRBInfo->i64Size = 0;
2026 pSHQueryRBInfo->i64NumItems = 0;
2031 /*************************************************************************
2032 * SHSetLocalizedName (SHELL32.@)
2034 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
2036 FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
2041 /*************************************************************************
2042 * LinkWindow_RegisterClass (SHELL32.258)
2044 BOOL WINAPI LinkWindow_RegisterClass(void)
2050 /*************************************************************************
2051 * LinkWindow_UnregisterClass (SHELL32.259)
2053 BOOL WINAPI LinkWindow_UnregisterClass(void)
2059 /*************************************************************************
2060 * SHFlushSFCache (SHELL32.526)
2062 * Notifies the shell that a user-specified special folder location has changed.
2065 * In Wine, the shell folder registry values are not cached, so this function
2068 void WINAPI SHFlushSFCache(void)
2072 HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv)
2074 FIXME("STUB: %i %s\n",iImageList,debugstr_guid(riid));
2075 return E_NOINTERFACE;