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"
43 #include "shell32_main.h"
44 #include "undocshell.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(shell);
50 WINE_DECLARE_DEBUG_CHANNEL(pidl);
52 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
53 /* !!! it is in both here and comctl32undoc.c !!! */
54 typedef struct tagCREATEMRULIST
56 DWORD cbSize; /* size of struct */
57 DWORD nMaxItems; /* max no. of items in list */
58 DWORD dwFlags; /* see below */
59 HKEY hKey; /* root reg. key under which list is saved */
60 LPCSTR lpszSubKey; /* reg. subkey */
61 PROC lpfnCompare; /* item compare proc */
62 } CREATEMRULISTA, *LPCREATEMRULISTA;
65 #define MRUF_STRING_LIST 0 /* list will contain strings */
66 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
67 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
69 extern HANDLE WINAPI CreateMRUListA(LPCREATEMRULISTA lpcml);
70 extern DWORD WINAPI FreeMRUList(HANDLE hMRUList);
71 extern INT WINAPI AddMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData);
72 extern INT WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
73 extern INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
76 /* Get a function pointer from a DLL handle */
77 #define GET_FUNC(func, module, name, fail) \
80 if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
81 func = (void*)GetProcAddress(SHELL32_h##module, name); \
82 if (!func) return fail; \
86 /* Function pointers for GET_FUNC macro */
87 static HMODULE SHELL32_hshlwapi=NULL;
88 static HANDLE (WINAPI *pSHAllocShared)(LPCVOID,DWORD,DWORD);
89 static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD);
90 static BOOL (WINAPI *pSHUnlockShared)(LPVOID);
91 static BOOL (WINAPI *pSHFreeShared)(HANDLE,DWORD);
94 /*************************************************************************
95 * ParseFieldA [internal]
97 * copies a field from a ',' delimited string
99 * first field is nField = 1
101 DWORD WINAPI ParseFieldA(
107 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src),nField,dst,len);
109 if (!src || !src[0] || !dst || !len)
112 /* skip n fields delimited by ',' */
115 if (*src=='\0') return FALSE;
116 if (*(src++)==',') nField--;
119 /* copy part till the next ',' to dst */
120 while ( *src!='\0' && *src!=',' && (len--)>0 ) *(dst++)=*(src++);
122 /* finalize the string */
128 /*************************************************************************
129 * ParseFieldW [internal]
131 * copies a field from a ',' delimited string
133 * first field is nField = 1
135 DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len)
137 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src), nField, dst, len);
139 if (!src || !src[0] || !dst || !len)
142 /* skip n fields delimited by ',' */
145 if (*src == 0x0) return FALSE;
146 if (*src++ == ',') nField--;
149 /* copy part till the next ',' to dst */
150 while ( *src != 0x0 && *src != ',' && (len--)>0 ) *(dst++) = *(src++);
152 /* finalize the string */
158 /*************************************************************************
159 * ParseField [SHELL32.58]
161 DWORD WINAPI ParseFieldAW(LPCVOID src, DWORD nField, LPVOID dst, DWORD len)
163 if (SHELL_OsIsUnicode())
164 return ParseFieldW(src, nField, dst, len);
165 return ParseFieldA(src, nField, dst, len);
168 /*************************************************************************
169 * GetFileNameFromBrowse [SHELL32.63]
172 BOOL WINAPI GetFileNameFromBrowse(
176 LPCSTR lpstrInitialDir,
182 FARPROC pGetOpenFileNameA;
186 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
187 hwndOwner, lpstrFile, nMaxFile, lpstrInitialDir, lpstrDefExt,
188 lpstrFilter, lpstrTitle);
190 hmodule = LoadLibraryA("comdlg32.dll");
191 if(!hmodule) return FALSE;
192 pGetOpenFileNameA = GetProcAddress(hmodule, "GetOpenFileNameA");
193 if(!pGetOpenFileNameA)
195 FreeLibrary(hmodule);
199 memset(&ofn, 0, sizeof(ofn));
201 ofn.lStructSize = sizeof(ofn);
202 ofn.hwndOwner = hwndOwner;
203 ofn.lpstrFilter = lpstrFilter;
204 ofn.lpstrFile = lpstrFile;
205 ofn.nMaxFile = nMaxFile;
206 ofn.lpstrInitialDir = lpstrInitialDir;
207 ofn.lpstrTitle = lpstrTitle;
208 ofn.lpstrDefExt = lpstrDefExt;
209 ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
210 ret = pGetOpenFileNameA(&ofn);
212 FreeLibrary(hmodule);
216 /*************************************************************************
217 * SHGetSetSettings [SHELL32.68]
219 VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
223 FIXME("%p 0x%08x TRUE\n", lpss, dwMask);
227 SHGetSettings((LPSHELLFLAGSTATE)lpss,dwMask);
231 /*************************************************************************
232 * SHGetSettings [SHELL32.@]
235 * the registry path are for win98 (tested)
236 * and possibly are the same in nt40
239 VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask)
243 DWORD dwDataSize = sizeof (DWORD);
245 TRACE("(%p 0x%08x)\n",lpsfs,dwMask);
247 if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
248 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0))
251 if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize))
252 lpsfs->fShowExtensions = ((dwData == 0) ? 0 : 1);
254 if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize))
255 lpsfs->fShowInfoTip = ((dwData == 0) ? 0 : 1);
257 if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize))
258 lpsfs->fDontPrettyPath = ((dwData == 0) ? 0 : 1);
260 if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize))
261 lpsfs->fHideIcons = ((dwData == 0) ? 0 : 1);
263 if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize))
264 lpsfs->fMapNetDrvBtn = ((dwData == 0) ? 0 : 1);
266 if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize))
267 lpsfs->fShowAttribCol = ((dwData == 0) ? 0 : 1);
269 if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize))
271 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
272 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
274 else if (dwData == 1)
275 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 1;
276 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
278 else if (dwData == 2)
279 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
280 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 1;
285 TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
288 /*************************************************************************
289 * SHShellFolderView_Message [SHELL32.73]
291 * Send a message to an explorer cabinet window.
294 * hwndCabinet [I] The window containing the shellview to communicate with
295 * dwMessage [I] The SFVM message to send
296 * dwParam [I] Message parameter
302 * Message SFVM_REARRANGE = 1
304 * This message gets sent when a column gets clicked to instruct the
305 * shell view to re-sort the item list. dwParam identifies the column
308 LRESULT WINAPI SHShellFolderView_Message(
313 FIXME("%p %08x %08lx stub\n",hwndCabinet, uMessage, lParam);
317 /*************************************************************************
318 * RegisterShellHook [SHELL32.181]
320 * Register a shell hook.
323 * hwnd [I] Window handle
324 * dwType [I] Type of hook.
327 * Exported by ordinal
329 BOOL WINAPI RegisterShellHook(
333 FIXME("(%p,0x%08x):stub.\n",hWnd, dwType);
337 /*************************************************************************
338 * ShellMessageBoxW [SHELL32.182]
340 * See ShellMessageBoxA.
343 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
344 * because we can't forward to it in the .spec file since it's exported by
345 * ordinal. If you change the implementation here please update the code in
348 int WINAPIV ShellMessageBoxW(
356 WCHAR szText[100],szTitle[100];
357 LPCWSTR pszText = szText, pszTitle = szTitle;
362 va_start(args, uType);
363 /* wvsprintfA(buf,fmt, args); */
365 TRACE("(%p,%p,%p,%p,%08x)\n",
366 hInstance,hWnd,lpText,lpCaption,uType);
368 if (IS_INTRESOURCE(lpCaption))
369 LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
371 pszTitle = lpCaption;
373 if (IS_INTRESOURCE(lpText))
374 LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
378 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
379 pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
383 ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
384 LocalFree((HLOCAL)pszTemp);
388 /*************************************************************************
389 * ShellMessageBoxA [SHELL32.183]
391 * Format and output an error message.
394 * hInstance [I] Instance handle of message creator
395 * hWnd [I] Window handle of message creator
396 * lpText [I] Resource Id of title or LPSTR
397 * lpCaption [I] Resource Id of title or LPSTR
398 * uType [I] Type of error message
401 * A return value from MessageBoxA().
404 * Exported by ordinal
406 int WINAPIV ShellMessageBoxA(
414 char szText[100],szTitle[100];
415 LPCSTR pszText = szText, pszTitle = szTitle;
420 va_start(args, uType);
421 /* wvsprintfA(buf,fmt, args); */
423 TRACE("(%p,%p,%p,%p,%08x)\n",
424 hInstance,hWnd,lpText,lpCaption,uType);
426 if (IS_INTRESOURCE(lpCaption))
427 LoadStringA(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle));
429 pszTitle = lpCaption;
431 if (IS_INTRESOURCE(lpText))
432 LoadStringA(hInstance, LOWORD(lpText), szText, sizeof(szText));
436 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
437 pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
441 ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
442 LocalFree((HLOCAL)pszTemp);
446 /*************************************************************************
447 * SHRegisterDragDrop [SHELL32.86]
449 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
450 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
451 * for details. Under Windows 98 this function initializes the true OLE when called
452 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
454 * We follow Windows 98 behaviour.
457 * exported by ordinal
460 * RegisterDragDrop, SHLoadOLE
462 HRESULT WINAPI SHRegisterDragDrop(
464 LPDROPTARGET pDropTarget)
466 static BOOL ole_initialized = FALSE;
469 TRACE("(%p,%p)\n", hWnd, pDropTarget);
471 if (!ole_initialized)
473 hr = OleInitialize(NULL);
476 ole_initialized = TRUE;
478 return RegisterDragDrop(hWnd, pDropTarget);
481 /*************************************************************************
482 * SHRevokeDragDrop [SHELL32.87]
484 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
485 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
486 * for details. Function removed from Windows Vista.
488 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
492 * exported by ordinal
495 * RevokeDragDrop, SHLoadOLE
497 HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
499 TRACE("(%p)\n", hWnd);
500 return RevokeDragDrop(hWnd);
503 /*************************************************************************
504 * SHDoDragDrop [SHELL32.88]
506 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
507 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
511 * exported by ordinal
514 * DoDragDrop, SHLoadOLE
516 HRESULT WINAPI SHDoDragDrop(
518 LPDATAOBJECT lpDataObject,
519 LPDROPSOURCE lpDropSource,
523 FIXME("(%p %p %p 0x%08x %p):stub.\n",
524 hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
525 return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
528 /*************************************************************************
529 * ArrangeWindows [SHELL32.184]
532 WORD WINAPI ArrangeWindows(
539 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
540 hwndParent, dwReserved, lpRect, cKids, lpKids);
544 /*************************************************************************
545 * SignalFileOpen [SHELL32.103]
548 * exported by ordinal
551 SignalFileOpen (DWORD dwParam1)
553 FIXME("(0x%08x):stub.\n", dwParam1);
558 /*************************************************************************
559 * SHADD_get_policy - helper function for SHAddToRecentDocs
562 * policy [IN] policy name (null termed string) to find
563 * type [OUT] ptr to DWORD to receive type
564 * buffer [OUT] ptr to area to hold data retrieved
565 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
569 * result of the SHQueryValueEx call
571 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
576 /* Get the key for the policies location in the registry
578 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
579 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
580 0, KEY_READ, &Policy_basekey)) {
582 if (RegOpenKeyExA(HKEY_CURRENT_USER,
583 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
584 0, KEY_READ, &Policy_basekey)) {
585 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
588 return ERROR_FILE_NOT_FOUND;
592 /* Retrieve the data if it exists
594 ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len);
595 RegCloseKey(Policy_basekey);
600 /*************************************************************************
601 * SHADD_compare_mru - helper function for SHAddToRecentDocs
604 * data1 [IN] data being looked for
605 * data2 [IN] data in MRU
606 * cbdata [IN] length from FindMRUData call (not used)
609 * position within MRU list that data was added.
611 static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData)
613 return lstrcmpiA(data1, data2);
616 /*************************************************************************
617 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
620 * mruhandle [IN] handle for created MRU list
621 * doc_name [IN] null termed pure doc name
622 * new_lnk_name [IN] null termed path and file name for .lnk file
623 * buffer [IN/OUT] 2048 byte area to construct MRU data
624 * len [OUT] ptr to int to receive space used in buffer
627 * position within MRU list that data was added.
629 static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPCSTR doc_name, LPCSTR new_lnk_name,
630 LPSTR buffer, INT *len)
636 * RecentDocs MRU data structure seems to be:
637 * +0h document file name w/ terminating 0h
638 * +nh short int w/ size of remaining
639 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
640 * +n+4h 10 bytes zeros - unknown
641 * +n+eh shortcut file name w/ terminating 0h
642 * +n+e+nh 3 zero bytes - unknown
645 /* Create the MRU data structure for "RecentDocs"
648 lstrcpyA(ptr, doc_name);
649 ptr += (lstrlenA(buffer) + 1);
650 wlen= lstrlenA(new_lnk_name) + 1 + 12;
651 *((short int*)ptr) = wlen;
652 ptr += 2; /* step past the length */
653 *(ptr++) = 0x30; /* unknown reason */
654 *(ptr++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
657 lstrcpyA(ptr, new_lnk_name);
658 ptr += (lstrlenA(new_lnk_name) + 1);
663 /* Add the new entry into the MRU list
665 return AddMRUData(mruhandle, (LPCVOID)buffer, *len);
668 /*************************************************************************
669 * SHAddToRecentDocs [SHELL32.@]
671 * Modify (add/clear) Shell's list of recently used documents.
674 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
675 * pv [IN] string or pidl, NULL clears the list
683 void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
685 /* If list is a string list lpfnCompare has the following prototype
686 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
687 * for binary lists the prototype is
688 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
689 * where cbData is the no. of bytes to compare.
690 * Need to check what return value means identical - 0?
696 CHAR doc_name[MAX_PATH];
697 CHAR link_dir[MAX_PATH];
698 CHAR new_lnk_filepath[MAX_PATH];
699 CHAR new_lnk_name[MAX_PATH];
702 HWND hwnd = 0; /* FIXME: get real window handle */
704 DWORD data[64], datalen, type;
706 TRACE("%04x %p\n", uFlags, pv);
709 * RecentDocs MRU data structure seems to be:
710 * +0h document file name w/ terminating 0h
711 * +nh short int w/ size of remaining
712 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
713 * +n+4h 10 bytes zeros - unknown
714 * +n+eh shortcut file name w/ terminating 0h
715 * +n+e+nh 3 zero bytes - unknown
718 /* See if we need to do anything.
721 ret=SHADD_get_policy( "NoRecentDocsHistory", &type, &data, &datalen);
722 if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) {
723 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret);
726 if (ret == ERROR_SUCCESS) {
727 if (!( (type == REG_DWORD) ||
728 ((type == REG_BINARY) && (datalen == 4)) )) {
729 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
734 TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
735 /* now test the actual policy value */
740 /* Open key to where the necessary info is
742 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
743 * and the close should be done during the _DETACH. The resulting
744 * key is stored in the DLL global data.
746 if (RegCreateKeyExA(HKEY_CURRENT_USER,
747 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
748 0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
749 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
753 /* Get path to user's "Recent" directory
755 if(SUCCEEDED(SHGetMalloc(&ppM))) {
756 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
758 SHGetPathFromIDListA(pidl, link_dir);
759 IMalloc_Free(ppM, pidl);
764 ERR("serious issues 1\n");
766 IMalloc_Release(ppM);
771 ERR("serious issues 2\n");
773 TRACE("Users Recent dir %s\n", link_dir);
775 /* If no input, then go clear the lists */
777 /* clear user's Recent dir
780 /* FIXME: delete all files in "link_dir"
782 * while( more files ) {
783 * lstrcpyA(old_lnk_name, link_dir);
784 * PathAppendA(old_lnk_name, filenam);
785 * DeleteFileA(old_lnk_name);
788 FIXME("should delete all files in %s\\\n", link_dir);
792 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
793 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
794 * and naturally it fails w/ rc=2. It should do it against
795 * HKEY_CURRENT_USER which is where it is stored, and where
796 * the MRU routines expect it!!!!
798 RegDeleteKeyA(HCUbasekey, "RecentDocs");
799 RegCloseKey(HCUbasekey);
803 /* Have data to add, the jobs to be done:
804 * 1. Add document to MRU list in registry "HKCU\Software\
805 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
806 * 2. Add shortcut to document in the user's Recent directory
808 * 3. Add shortcut to Start menu's Documents submenu.
811 /* Get the pure document name from the input
816 SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name);
820 lstrcpynA(doc_name, (LPCSTR)pv, MAX_PATH);
824 WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pv, -1, doc_name, MAX_PATH, NULL, NULL);
828 FIXME("Unsupported flags: %u\n", uFlags);
832 TRACE("full document name %s\n", debugstr_a(doc_name));
833 PathStripPathA(doc_name);
834 TRACE("stripped document name %s\n", debugstr_a(doc_name));
837 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
840 * doc_name - pure file-spec, no path
841 * link_dir - path to the user's Recent directory
842 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
844 * new_lnk_name- pure file-spec, no path for new .lnk file
846 * - path and file name of new .lnk file
848 CREATEMRULISTA mymru;
850 INT len, pos, bufused, err;
855 CHAR old_lnk_name[MAX_PATH];
858 mymru.cbSize = sizeof(CREATEMRULISTA);
859 mymru.nMaxItems = 15;
860 mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE;
861 mymru.hKey = HCUbasekey;
862 mymru.lpszSubKey = "RecentDocs";
863 mymru.lpfnCompare = (PROC)SHADD_compare_mru;
864 mruhandle = CreateMRUListA(&mymru);
867 ERR("MRU processing failed, handle zero\n");
868 RegCloseKey(HCUbasekey);
871 len = lstrlenA(doc_name);
872 pos = FindMRUData(mruhandle, doc_name, len, 0);
874 /* Now get the MRU entry that will be replaced
875 * and delete the .lnk file for it
877 if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos,
878 buffer, 2048)) != -1) {
880 ptr += (lstrlenA(buffer) + 1);
881 slen = *((short int*)ptr);
882 ptr += 2; /* skip the length area */
883 if (bufused >= slen + (ptr-buffer)) {
884 /* buffer size looks good */
885 ptr += 12; /* get to string */
886 len = bufused - (ptr-buffer); /* get length of buf remaining */
887 if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
888 /* appears to be good string */
889 lstrcpyA(old_lnk_name, link_dir);
890 PathAppendA(old_lnk_name, ptr);
891 if (!DeleteFileA(old_lnk_name)) {
892 if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
893 if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
894 ERR("Delete for %s failed, err=%d, attr=%08x\n",
895 old_lnk_name, err, attr);
898 TRACE("old .lnk file %s did not exist\n",
903 ERR("Delete for %s failed, attr=%08x\n",
908 TRACE("deleted old .lnk file %s\n", old_lnk_name);
914 /* Create usable .lnk file name for the "Recent" directory
916 wsprintfA(new_lnk_name, "%s.lnk", doc_name);
917 lstrcpyA(new_lnk_filepath, link_dir);
918 PathAppendA(new_lnk_filepath, new_lnk_name);
920 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
921 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
923 wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
924 lstrcpyA(new_lnk_filepath, link_dir);
925 PathAppendA(new_lnk_filepath, new_lnk_name);
927 SetErrorMode(olderrormode);
928 TRACE("new shortcut will be %s\n", new_lnk_filepath);
930 /* Now add the new MRU entry and data
932 pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name,
934 FreeMRUList(mruhandle);
935 TRACE("Updated MRU list, new doc is position %d\n", pos);
938 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
941 * doc_name - pure file-spec, no path
943 * - path and file name of new .lnk file
944 * uFlags[in] - flags on call to SHAddToRecentDocs
945 * pv[in] - document path/pidl on call to SHAddToRecentDocs
947 IShellLinkA *psl = NULL;
948 IPersistFile *pPf = NULL;
951 WCHAR widelink[MAX_PATH];
955 hres = CoCreateInstance( &CLSID_ShellLink,
957 CLSCTX_INPROC_SERVER,
960 if(SUCCEEDED(hres)) {
962 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
966 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
970 /* Set the document path or pidl */
971 if (uFlags == SHARD_PIDL) {
972 hres = IShellLinkA_SetIDList(psl, (LPCITEMIDLIST) pv);
974 hres = IShellLinkA_SetPath(psl, (LPCSTR) pv);
978 ERR("failed Set{IDList|Path} %08x\n", hres);
982 lstrcpyA(desc, "Shortcut to ");
983 lstrcatA(desc, doc_name);
984 hres = IShellLinkA_SetDescription(psl, desc);
987 ERR("failed SetDescription %08x\n", hres);
991 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
993 /* create the short cut */
994 hres = IPersistFile_Save(pPf, widelink, TRUE);
997 ERR("failed IPersistFile::Save %08x\n", hres);
998 IPersistFile_Release(pPf);
999 IShellLinkA_Release(psl);
1002 hres = IPersistFile_SaveCompleted(pPf, widelink);
1003 IPersistFile_Release(pPf);
1004 IShellLinkA_Release(psl);
1005 TRACE("shortcut %s has been created, result=%08x\n",
1006 new_lnk_filepath, hres);
1009 ERR("CoCreateInstance failed, hres=%08x\n", hres);
1017 RegCloseKey(HCUbasekey);
1021 /*************************************************************************
1022 * SHCreateShellFolderViewEx [SHELL32.174]
1024 * Create a new instance of the default Shell folder view object.
1028 * Failure: error value
1031 * see IShellFolder::CreateViewObject
1033 HRESULT WINAPI SHCreateShellFolderViewEx(
1034 LPCSFV psvcbi, /* [in] shelltemplate struct */
1035 IShellView **ppv) /* [out] IShellView pointer */
1040 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1041 psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
1042 psvcbi->fvm, psvcbi->psvOuter);
1044 psf = IShellView_Constructor(psvcbi->pshf);
1047 return E_OUTOFMEMORY;
1049 IShellView_AddRef(psf);
1050 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1051 IShellView_Release(psf);
1055 /*************************************************************************
1056 * SHWinHelp [SHELL32.127]
1059 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
1060 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v,w,x,z);
1063 /*************************************************************************
1064 * SHRunControlPanel [SHELL32.161]
1067 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
1068 { FIXME("0x%08x 0x%08x stub\n",x,z);
1072 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1073 /*************************************************************************
1074 * SHSetInstanceExplorer [SHELL32.176]
1077 * Sets the interface
1079 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1080 { TRACE("%p\n", lpUnknown);
1081 SHELL32_IExplorerInterface = lpUnknown;
1083 /*************************************************************************
1084 * SHGetInstanceExplorer [SHELL32.@]
1087 * gets the interface pointer of the explorer and a reference
1089 HRESULT WINAPI SHGetInstanceExplorer (IUnknown **lpUnknown)
1090 { TRACE("%p\n", lpUnknown);
1092 *lpUnknown = SHELL32_IExplorerInterface;
1094 if (!SHELL32_IExplorerInterface)
1097 IUnknown_AddRef(SHELL32_IExplorerInterface);
1100 /*************************************************************************
1101 * SHFreeUnusedLibraries [SHELL32.123]
1103 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1104 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1108 * exported by ordinal
1111 * CoFreeUnusedLibraries, SHLoadOLE
1113 void WINAPI SHFreeUnusedLibraries (void)
1116 CoFreeUnusedLibraries();
1118 /*************************************************************************
1119 * DAD_AutoScroll [SHELL32.129]
1122 BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, LPPOINT pt)
1124 FIXME("hwnd = %p %p %p\n",hwnd,samples,pt);
1127 /*************************************************************************
1128 * DAD_DragEnter [SHELL32.130]
1131 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1133 FIXME("hwnd = %p\n",hwnd);
1136 /*************************************************************************
1137 * DAD_DragEnterEx [SHELL32.131]
1140 BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p)
1142 FIXME("hwnd = %p (%d,%d)\n",hwnd,p.x,p.y);
1145 /*************************************************************************
1146 * DAD_DragMove [SHELL32.134]
1149 BOOL WINAPI DAD_DragMove(POINT p)
1151 FIXME("(%d,%d)\n",p.x,p.y);
1154 /*************************************************************************
1155 * DAD_DragLeave [SHELL32.132]
1158 BOOL WINAPI DAD_DragLeave(VOID)
1163 /*************************************************************************
1164 * DAD_SetDragImage [SHELL32.136]
1169 BOOL WINAPI DAD_SetDragImage(
1170 HIMAGELIST himlTrack,
1173 FIXME("%p %p stub\n",himlTrack, lppt);
1176 /*************************************************************************
1177 * DAD_ShowDragImage [SHELL32.137]
1182 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1184 FIXME("0x%08x stub\n",bShow);
1188 static const WCHAR szwCabLocation[] = {
1189 'S','o','f','t','w','a','r','e','\\',
1190 'M','i','c','r','o','s','o','f','t','\\',
1191 'W','i','n','d','o','w','s','\\',
1192 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1193 'E','x','p','l','o','r','e','r','\\',
1194 'C','a','b','i','n','e','t','S','t','a','t','e',0
1197 static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 };
1199 /*************************************************************************
1200 * ReadCabinetState [SHELL32.651] NT 4.0
1203 BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
1208 TRACE("%p %d\n", cs, length);
1210 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1213 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1214 if( r == ERROR_SUCCESS )
1217 r = RegQueryValueExW( hkey, szwSettings,
1218 NULL, &type, (LPBYTE)cs, (LPDWORD)&length );
1219 RegCloseKey( hkey );
1223 /* if we can't read from the registry, create default values */
1224 if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) ||
1225 (cs->cLength != length) )
1227 ERR("Initializing shell cabinet settings\n");
1228 memset(cs, 0, sizeof(*cs));
1229 cs->cLength = sizeof(*cs);
1231 cs->fFullPathTitle = FALSE;
1232 cs->fSaveLocalView = TRUE;
1233 cs->fNotShell = FALSE;
1234 cs->fSimpleDefault = TRUE;
1235 cs->fDontShowDescBar = FALSE;
1236 cs->fNewWindowMode = FALSE;
1237 cs->fShowCompColor = FALSE;
1238 cs->fDontPrettyNames = FALSE;
1239 cs->fAdminsCreateCommonGroups = TRUE;
1240 cs->fMenuEnumFilter = 96;
1246 /*************************************************************************
1247 * WriteCabinetState [SHELL32.652] NT 4.0
1250 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1260 r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0,
1261 NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
1262 if( r == ERROR_SUCCESS )
1264 r = RegSetValueExW( hkey, szwSettings, 0,
1265 REG_BINARY, (LPBYTE) cs, cs->cLength);
1267 RegCloseKey( hkey );
1270 return (r==ERROR_SUCCESS);
1273 /*************************************************************************
1274 * FileIconInit [SHELL32.660]
1277 BOOL WINAPI FileIconInit(BOOL bFullInit)
1278 { FIXME("(%s)\n", bFullInit ? "true" : "false");
1281 /*************************************************************************
1282 * IsUserAdmin [SHELL32.680] NT 4.0
1285 HRESULT WINAPI IsUserAdmin(void)
1290 /*************************************************************************
1291 * SHAllocShared [SHELL32.520]
1293 * See shlwapi.SHAllocShared
1295 HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
1297 GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
1298 return pSHAllocShared(lpvData, dwSize, dwProcId);
1301 /*************************************************************************
1302 * SHLockShared [SHELL32.521]
1304 * See shlwapi.SHLockShared
1306 LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
1308 GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
1309 return pSHLockShared(hShared, dwProcId);
1312 /*************************************************************************
1313 * SHUnlockShared [SHELL32.522]
1315 * See shlwapi.SHUnlockShared
1317 BOOL WINAPI SHUnlockShared(LPVOID lpView)
1319 GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
1320 return pSHUnlockShared(lpView);
1323 /*************************************************************************
1324 * SHFreeShared [SHELL32.523]
1326 * See shlwapi.SHFreeShared
1328 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
1330 GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
1331 return pSHFreeShared(hShared, dwProcId);
1334 /*************************************************************************
1335 * SetAppStartingCursor [SHELL32.99]
1337 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1338 { FIXME("hwnd=%p 0x%04x stub\n",u,v );
1342 /*************************************************************************
1343 * SHLoadOLE [SHELL32.151]
1345 * To reduce the memory usage of Windows 95, its shell32 contained an
1346 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1347 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1348 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1349 * would just call the Co* functions.
1351 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1352 * information from the shell32 "mini-COM" to ole32.dll.
1354 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1355 * detailed description.
1357 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1358 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1359 * hack in SHCoCreateInstance)
1361 HRESULT WINAPI SHLoadOLE(LPARAM lParam)
1362 { FIXME("0x%08lx stub\n",lParam);
1365 /*************************************************************************
1366 * DriveType [SHELL32.64]
1369 HRESULT WINAPI DriveType(DWORD u)
1370 { FIXME("0x%04x stub\n",u);
1373 /*************************************************************************
1374 * InvalidateDriveType [SHELL32.65]
1377 int WINAPI InvalidateDriveType(int u)
1378 { FIXME("0x%08x stub\n",u);
1381 /*************************************************************************
1382 * SHAbortInvokeCommand [SHELL32.198]
1385 HRESULT WINAPI SHAbortInvokeCommand(void)
1389 /*************************************************************************
1390 * SHOutOfMemoryMessageBox [SHELL32.126]
1393 int WINAPI SHOutOfMemoryMessageBox(
1398 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1401 /*************************************************************************
1402 * SHFlushClipboard [SHELL32.121]
1405 HRESULT WINAPI SHFlushClipboard(void)
1410 /*************************************************************************
1411 * SHWaitForFileToOpen [SHELL32.97]
1414 BOOL WINAPI SHWaitForFileToOpen(
1419 FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1423 /************************************************************************
1427 * first parameter seems to be a pointer (same as passed to WriteCabinetState)
1428 * second one could be a size (0x0c). The size is the same as the structure saved to
1429 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1430 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1432 HRESULT WINAPI shell32_654 (CABINETSTATE *cs, int length)
1434 TRACE("%p %d\n",cs,length);
1435 return ReadCabinetState(cs,length);
1438 /************************************************************************
1439 * RLBuildListOfPaths [SHELL32.146]
1444 DWORD WINAPI RLBuildListOfPaths (void)
1448 /************************************************************************
1449 * SHValidateUNC [SHELL32.173]
1452 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1454 FIXME("0x%08x 0x%08x 0x%08x stub\n",x,y,z);
1458 /************************************************************************
1459 * DoEnvironmentSubstA [SHELL32.@]
1461 * Replace %KEYWORD% in the str with the value of variable KEYWORD
1462 * from environment. If it is not found the %KEYWORD% is left
1463 * intact. If the buffer is too small, str is not modified.
1466 * pszString [I] '\0' terminated string with %keyword%.
1467 * [O] '\0' terminated string with %keyword% substituted.
1468 * cchString [I] size of str.
1471 * cchString length in the HIWORD;
1472 * TRUE in LOWORD if subst was successful and FALSE in other case
1474 DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
1478 FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
1479 if (pszString == NULL) /* Really return 0? */
1481 if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
1483 DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
1484 if (num && num < cchString) /* dest buffer is too small */
1487 memcpy(pszString, dst, num);
1489 HeapFree(GetProcessHeap(), 0, dst);
1491 return MAKELONG(res,cchString); /* Always cchString? */
1494 /************************************************************************
1495 * DoEnvironmentSubstW [SHELL32.@]
1497 * See DoEnvironmentSubstA.
1499 DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
1501 FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
1502 return MAKELONG(FALSE,cchString);
1505 /************************************************************************
1506 * DoEnvironmentSubst [SHELL32.53]
1508 * See DoEnvironmentSubstA.
1510 DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y)
1512 if (SHELL_OsIsUnicode())
1513 return DoEnvironmentSubstW(x, y);
1514 return DoEnvironmentSubstA(x, y);
1517 /*************************************************************************
1520 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1521 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1525 BOOL WINAPI shell32_243(DWORD a, DWORD b)
1530 /*************************************************************************
1533 DWORD WINAPI SHELL32_714(LPVOID x)
1535 FIXME("(%s)stub\n", debugstr_w(x));
1539 typedef struct _PSXA
1543 IShellPropSheetExt *pspsx[1];
1546 typedef struct _PSXA_CALL
1548 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith;
1553 } PSXA_CALL, *PPSXA_CALL;
1555 static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam)
1557 PPSXA_CALL Call = (PPSXA_CALL)lParam;
1561 if ((Call->bMultiple || !Call->bCalled) &&
1562 Call->lpfnAddReplaceWith(hpage, Call->lParam))
1564 Call->bCalled = TRUE;
1573 /*************************************************************************
1574 * SHAddFromPropSheetExtArray [SHELL32.167]
1576 UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
1580 PPSXA psxa = (PPSXA)hpsxa;
1582 TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam);
1586 ZeroMemory(&Call, sizeof(Call));
1587 Call.lpfnAddReplaceWith = lpfnAddPage;
1588 Call.lParam = lParam;
1589 Call.bMultiple = TRUE;
1591 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1592 for (i = 0; i != psxa->uiCount; i++)
1594 psxa->pspsx[i]->lpVtbl->AddPages(psxa->pspsx[i], PsxaCall, (LPARAM)&Call);
1597 return Call.uiCount;
1603 /*************************************************************************
1604 * SHCreatePropSheetExtArray [SHELL32.168]
1606 HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
1608 return SHCreatePropSheetExtArrayEx(hKey, pszSubKey, max_iface, NULL);
1611 /*************************************************************************
1612 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1614 HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, LPDATAOBJECT pDataObj)
1616 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};
1617 WCHAR szHandler[64];
1619 WCHAR szClsidHandler[39];
1624 IShellExtInit *psxi;
1625 IShellPropSheetExt *pspsx;
1626 HKEY hkBase, hkPropSheetHandlers;
1629 TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface);
1634 /* Open the registry key */
1635 lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase);
1636 if (lRet != ERROR_SUCCESS)
1639 lRet = RegOpenKeyExW(hkBase, szPropSheetSubKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkPropSheetHandlers);
1640 RegCloseKey(hkBase);
1641 if (lRet == ERROR_SUCCESS)
1643 /* Create and initialize the Property Sheet Extensions Array */
1644 psxa = (PPSXA)LocalAlloc(LMEM_FIXED, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1647 ZeroMemory(psxa, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1648 psxa->uiAllocated = max_iface;
1650 /* Enumerate all subkeys and attempt to load the shell extensions */
1654 dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]);
1655 lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL);
1656 if (lRet != ERROR_SUCCESS)
1658 if (lRet == ERROR_MORE_DATA)
1661 if (lRet == ERROR_NO_MORE_ITEMS)
1662 lRet = ERROR_SUCCESS;
1666 dwClsidSize = sizeof(szClsidHandler);
1667 if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
1669 /* Force a NULL-termination and convert the string */
1670 szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
1671 if (SUCCEEDED(SHCLSIDFromStringW(szClsidHandler, &clsid)))
1673 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1674 Only if both interfaces are supported it's a real shell extension.
1675 Then call IShellExtInit's Initialize method. */
1676 if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx)))
1678 if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi)))
1680 if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey)))
1682 /* Add the IShellPropSheetExt instance to the array */
1683 psxa->pspsx[psxa->uiCount++] = pspsx;
1687 psxi->lpVtbl->Release(psxi);
1688 pspsx->lpVtbl->Release(pspsx);
1692 pspsx->lpVtbl->Release(pspsx);
1697 } while (psxa->uiCount != psxa->uiAllocated);
1700 lRet = ERROR_NOT_ENOUGH_MEMORY;
1702 RegCloseKey(hkPropSheetHandlers);
1705 if (lRet != ERROR_SUCCESS && psxa)
1707 SHDestroyPropSheetExtArray((HPSXA)psxa);
1714 /*************************************************************************
1715 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1717 UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
1721 PPSXA psxa = (PPSXA)hpsxa;
1723 TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam);
1727 ZeroMemory(&Call, sizeof(Call));
1728 Call.lpfnAddReplaceWith = lpfnReplaceWith;
1729 Call.lParam = lParam;
1731 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1732 Each shell extension is only allowed to call the callback once during the callback. */
1733 for (i = 0; i != psxa->uiCount; i++)
1735 Call.bCalled = FALSE;
1736 psxa->pspsx[i]->lpVtbl->ReplacePage(psxa->pspsx[i], uPageID, PsxaCall, (LPARAM)&Call);
1739 return Call.uiCount;
1745 /*************************************************************************
1746 * SHDestroyPropSheetExtArray [SHELL32.169]
1748 void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
1751 PPSXA psxa = (PPSXA)hpsxa;
1753 TRACE("(%p)\n", hpsxa);
1757 for (i = 0; i != psxa->uiCount; i++)
1759 psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]);
1762 LocalFree((HLOCAL)psxa);
1766 /*************************************************************************
1767 * CIDLData_CreateFromIDArray [SHELL32.83]
1769 * Create IDataObject from PIDLs??
1771 HRESULT WINAPI CIDLData_CreateFromIDArray(
1772 LPCITEMIDLIST pidlFolder,
1774 LPCITEMIDLIST *lppidlFiles,
1775 LPDATAOBJECT *ppdataObject)
1778 HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */
1780 TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1784 for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1786 *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1787 lppidlFiles, cpidlFiles);
1788 if (*ppdataObject) return S_OK;
1789 return E_OUTOFMEMORY;
1792 /*************************************************************************
1793 * SHCreateStdEnumFmtEtc [SHELL32.74]
1798 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1800 const FORMATETC *lpFormats,
1801 LPENUMFORMATETC *ppenumFormatetc)
1803 IEnumFORMATETC *pef;
1805 TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1807 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1809 return E_OUTOFMEMORY;
1811 IEnumFORMATETC_AddRef(pef);
1812 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1813 IEnumFORMATETC_Release(pef);
1819 /*************************************************************************
1820 * SHELL32_256 (SHELL32.256)
1822 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1826 FIXME("stub %p 0x%08x %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1828 if (!lpdw0 || *lpdw0 != 0x10)
1832 LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1835 ret = E_OUTOFMEMORY;
1838 /* Initialize and return unknown lpdata structure */
1845 /*************************************************************************
1846 * SHFindFiles (SHELL32.90)
1848 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1850 FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1854 /*************************************************************************
1855 * SHUpdateImageW (SHELL32.192)
1857 * Notifies the shell that an icon in the system image list has been changed.
1860 * pszHashItem [I] Path to file that contains the icon.
1861 * iIndex [I] Zero-based index of the icon in the file.
1862 * uFlags [I] Flags determining the icon attributes. See notes.
1863 * iImageIndex [I] Index of the icon in the system image list.
1869 * uFlags can be one or more of the following flags:
1870 * GIL_NOTFILENAME - pszHashItem is not a file name.
1871 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1873 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
1875 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
1878 /*************************************************************************
1879 * SHUpdateImageA (SHELL32.191)
1881 * See SHUpdateImageW.
1883 VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex)
1885 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex);
1888 INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra)
1890 FIXME("%p - stub\n", pidlExtra);
1895 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
1897 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
1902 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
1905 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo), debugstr_a(pszDir),
1906 pszName, pfMustCopy, uFlags);
1911 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
1914 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
1915 pszName, pfMustCopy, uFlags);
1920 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
1922 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
1927 HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
1929 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1934 HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
1936 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1941 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
1943 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
1945 return SHFMT_NOFORMAT;
1948 HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1950 FIXME("%s, %p - stub\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1952 pSHQueryRBInfo->i64Size = 0;
1953 pSHQueryRBInfo->i64NumItems = 0;
1958 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1960 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1962 pSHQueryRBInfo->i64Size = 0;
1963 pSHQueryRBInfo->i64NumItems = 0;
1968 /*************************************************************************
1969 * SHSetLocalizedName (SHELL32.@)
1971 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
1973 FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
1978 /*************************************************************************
1979 * LinkWindow_RegisterClass (SHELL32.258)
1981 BOOL WINAPI LinkWindow_RegisterClass(void)
1987 /*************************************************************************
1988 * LinkWindow_UnregisterClass (SHELL32.259)
1990 BOOL WINAPI LinkWindow_UnregisterClass(void)