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 9x it could use the
450 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
454 * exported by ordinal
457 * RegisterDragDrop, SHLoadOLE
459 HRESULT WINAPI SHRegisterDragDrop(
461 LPDROPTARGET pDropTarget)
463 FIXME("(%p,%p):stub.\n", hWnd, pDropTarget);
464 return RegisterDragDrop(hWnd, pDropTarget);
467 /*************************************************************************
468 * SHRevokeDragDrop [SHELL32.87]
470 * Probably equivalent to RevokeDragDrop but under Windows 9x it could use the
471 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
475 * exported by ordinal
478 * RevokeDragDrop, SHLoadOLE
480 HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
482 FIXME("(%p):stub.\n",hWnd);
483 return RevokeDragDrop(hWnd);
486 /*************************************************************************
487 * SHDoDragDrop [SHELL32.88]
489 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
490 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
494 * exported by ordinal
497 * DoDragDrop, SHLoadOLE
499 HRESULT WINAPI SHDoDragDrop(
501 LPDATAOBJECT lpDataObject,
502 LPDROPSOURCE lpDropSource,
506 FIXME("(%p %p %p 0x%08x %p):stub.\n",
507 hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
508 return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
511 /*************************************************************************
512 * ArrangeWindows [SHELL32.184]
515 WORD WINAPI ArrangeWindows(
522 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
523 hwndParent, dwReserved, lpRect, cKids, lpKids);
527 /*************************************************************************
528 * SignalFileOpen [SHELL32.103]
531 * exported by ordinal
534 SignalFileOpen (DWORD dwParam1)
536 FIXME("(0x%08x):stub.\n", dwParam1);
541 /*************************************************************************
542 * SHADD_get_policy - helper function for SHAddToRecentDocs
545 * policy [IN] policy name (null termed string) to find
546 * type [OUT] ptr to DWORD to receive type
547 * buffer [OUT] ptr to area to hold data retrieved
548 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
552 * result of the SHQueryValueEx call
554 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
559 /* Get the key for the policies location in the registry
561 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
562 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
563 0, KEY_READ, &Policy_basekey)) {
565 if (RegOpenKeyExA(HKEY_CURRENT_USER,
566 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
567 0, KEY_READ, &Policy_basekey)) {
568 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
571 return ERROR_FILE_NOT_FOUND;
575 /* Retrieve the data if it exists
577 ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len);
578 RegCloseKey(Policy_basekey);
583 /*************************************************************************
584 * SHADD_compare_mru - helper function for SHAddToRecentDocs
587 * data1 [IN] data being looked for
588 * data2 [IN] data in MRU
589 * cbdata [IN] length from FindMRUData call (not used)
592 * position within MRU list that data was added.
594 static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData)
596 return lstrcmpiA(data1, data2);
599 /*************************************************************************
600 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
603 * mruhandle [IN] handle for created MRU list
604 * doc_name [IN] null termed pure doc name
605 * new_lnk_name [IN] null termed path and file name for .lnk file
606 * buffer [IN/OUT] 2048 byte area to construct MRU data
607 * len [OUT] ptr to int to receive space used in buffer
610 * position within MRU list that data was added.
612 static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPCSTR doc_name, LPCSTR new_lnk_name,
613 LPSTR buffer, INT *len)
619 * RecentDocs MRU data structure seems to be:
620 * +0h document file name w/ terminating 0h
621 * +nh short int w/ size of remaining
622 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
623 * +n+4h 10 bytes zeros - unknown
624 * +n+eh shortcut file name w/ terminating 0h
625 * +n+e+nh 3 zero bytes - unknown
628 /* Create the MRU data structure for "RecentDocs"
631 lstrcpyA(ptr, doc_name);
632 ptr += (lstrlenA(buffer) + 1);
633 wlen= lstrlenA(new_lnk_name) + 1 + 12;
634 *((short int*)ptr) = wlen;
635 ptr += 2; /* step past the length */
636 *(ptr++) = 0x30; /* unknown reason */
637 *(ptr++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
640 lstrcpyA(ptr, new_lnk_name);
641 ptr += (lstrlenA(new_lnk_name) + 1);
646 /* Add the new entry into the MRU list
648 return AddMRUData(mruhandle, (LPCVOID)buffer, *len);
651 /*************************************************************************
652 * SHAddToRecentDocs [SHELL32.@]
654 * Modify (add/clear) Shell's list of recently used documents.
657 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
658 * pv [IN] string or pidl, NULL clears the list
666 void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
668 /* If list is a string list lpfnCompare has the following prototype
669 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
670 * for binary lists the prototype is
671 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
672 * where cbData is the no. of bytes to compare.
673 * Need to check what return value means identical - 0?
679 CHAR doc_name[MAX_PATH];
680 CHAR link_dir[MAX_PATH];
681 CHAR new_lnk_filepath[MAX_PATH];
682 CHAR new_lnk_name[MAX_PATH];
685 HWND hwnd = 0; /* FIXME: get real window handle */
687 DWORD data[64], datalen, type;
689 TRACE("%04x %p\n", uFlags, pv);
692 * RecentDocs MRU data structure seems to be:
693 * +0h document file name w/ terminating 0h
694 * +nh short int w/ size of remaining
695 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
696 * +n+4h 10 bytes zeros - unknown
697 * +n+eh shortcut file name w/ terminating 0h
698 * +n+e+nh 3 zero bytes - unknown
701 /* See if we need to do anything.
704 ret=SHADD_get_policy( "NoRecentDocsHistory", &type, &data, &datalen);
705 if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) {
706 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret);
709 if (ret == ERROR_SUCCESS) {
710 if (!( (type == REG_DWORD) ||
711 ((type == REG_BINARY) && (datalen == 4)) )) {
712 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
717 TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
718 /* now test the actual policy value */
723 /* Open key to where the necessary info is
725 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
726 * and the close should be done during the _DETACH. The resulting
727 * key is stored in the DLL global data.
729 if (RegCreateKeyExA(HKEY_CURRENT_USER,
730 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
731 0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
732 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
736 /* Get path to user's "Recent" directory
738 if(SUCCEEDED(SHGetMalloc(&ppM))) {
739 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
741 SHGetPathFromIDListA(pidl, link_dir);
742 IMalloc_Free(ppM, pidl);
747 ERR("serious issues 1\n");
749 IMalloc_Release(ppM);
754 ERR("serious issues 2\n");
756 TRACE("Users Recent dir %s\n", link_dir);
758 /* If no input, then go clear the lists */
760 /* clear user's Recent dir
763 /* FIXME: delete all files in "link_dir"
765 * while( more files ) {
766 * lstrcpyA(old_lnk_name, link_dir);
767 * PathAppendA(old_lnk_name, filenam);
768 * DeleteFileA(old_lnk_name);
771 FIXME("should delete all files in %s\\\n", link_dir);
775 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
776 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
777 * and naturally it fails w/ rc=2. It should do it against
778 * HKEY_CURRENT_USER which is where it is stored, and where
779 * the MRU routines expect it!!!!
781 RegDeleteKeyA(HCUbasekey, "RecentDocs");
782 RegCloseKey(HCUbasekey);
786 /* Have data to add, the jobs to be done:
787 * 1. Add document to MRU list in registry "HKCU\Software\
788 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
789 * 2. Add shortcut to document in the user's Recent directory
791 * 3. Add shortcut to Start menu's Documents submenu.
794 /* Get the pure document name from the input
799 SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name);
803 lstrcpynA(doc_name, (LPCSTR)pv, MAX_PATH);
807 WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pv, -1, doc_name, MAX_PATH, NULL, NULL);
811 FIXME("Unsupported flags: %u\n", uFlags);
815 TRACE("full document name %s\n", debugstr_a(doc_name));
816 PathStripPathA(doc_name);
817 TRACE("stripped document name %s\n", debugstr_a(doc_name));
820 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
823 * doc_name - pure file-spec, no path
824 * link_dir - path to the user's Recent directory
825 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
827 * new_lnk_name- pure file-spec, no path for new .lnk file
829 * - path and file name of new .lnk file
831 CREATEMRULISTA mymru;
833 INT len, pos, bufused, err;
838 CHAR old_lnk_name[MAX_PATH];
841 mymru.cbSize = sizeof(CREATEMRULISTA);
842 mymru.nMaxItems = 15;
843 mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE;
844 mymru.hKey = HCUbasekey;
845 mymru.lpszSubKey = "RecentDocs";
846 mymru.lpfnCompare = (PROC)SHADD_compare_mru;
847 mruhandle = CreateMRUListA(&mymru);
850 ERR("MRU processing failed, handle zero\n");
851 RegCloseKey(HCUbasekey);
854 len = lstrlenA(doc_name);
855 pos = FindMRUData(mruhandle, doc_name, len, 0);
857 /* Now get the MRU entry that will be replaced
858 * and delete the .lnk file for it
860 if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos,
861 buffer, 2048)) != -1) {
863 ptr += (lstrlenA(buffer) + 1);
864 slen = *((short int*)ptr);
865 ptr += 2; /* skip the length area */
866 if (bufused >= slen + (ptr-buffer)) {
867 /* buffer size looks good */
868 ptr += 12; /* get to string */
869 len = bufused - (ptr-buffer); /* get length of buf remaining */
870 if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
871 /* appears to be good string */
872 lstrcpyA(old_lnk_name, link_dir);
873 PathAppendA(old_lnk_name, ptr);
874 if (!DeleteFileA(old_lnk_name)) {
875 if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
876 if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
877 ERR("Delete for %s failed, err=%d, attr=%08x\n",
878 old_lnk_name, err, attr);
881 TRACE("old .lnk file %s did not exist\n",
886 ERR("Delete for %s failed, attr=%08x\n",
891 TRACE("deleted old .lnk file %s\n", old_lnk_name);
897 /* Create usable .lnk file name for the "Recent" directory
899 wsprintfA(new_lnk_name, "%s.lnk", doc_name);
900 lstrcpyA(new_lnk_filepath, link_dir);
901 PathAppendA(new_lnk_filepath, new_lnk_name);
903 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
904 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
906 wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
907 lstrcpyA(new_lnk_filepath, link_dir);
908 PathAppendA(new_lnk_filepath, new_lnk_name);
910 SetErrorMode(olderrormode);
911 TRACE("new shortcut will be %s\n", new_lnk_filepath);
913 /* Now add the new MRU entry and data
915 pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name,
917 FreeMRUList(mruhandle);
918 TRACE("Updated MRU list, new doc is position %d\n", pos);
921 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
924 * doc_name - pure file-spec, no path
926 * - path and file name of new .lnk file
927 * uFlags[in] - flags on call to SHAddToRecentDocs
928 * pv[in] - document path/pidl on call to SHAddToRecentDocs
930 IShellLinkA *psl = NULL;
931 IPersistFile *pPf = NULL;
934 WCHAR widelink[MAX_PATH];
938 hres = CoCreateInstance( &CLSID_ShellLink,
940 CLSCTX_INPROC_SERVER,
943 if(SUCCEEDED(hres)) {
945 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
949 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
953 /* Set the document path or pidl */
954 if (uFlags == SHARD_PIDL) {
955 hres = IShellLinkA_SetIDList(psl, (LPCITEMIDLIST) pv);
957 hres = IShellLinkA_SetPath(psl, (LPCSTR) pv);
961 ERR("failed Set{IDList|Path} %08x\n", hres);
965 lstrcpyA(desc, "Shortcut to ");
966 lstrcatA(desc, doc_name);
967 hres = IShellLinkA_SetDescription(psl, desc);
970 ERR("failed SetDescription %08x\n", hres);
974 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
976 /* create the short cut */
977 hres = IPersistFile_Save(pPf, widelink, TRUE);
980 ERR("failed IPersistFile::Save %08x\n", hres);
981 IPersistFile_Release(pPf);
982 IShellLinkA_Release(psl);
985 hres = IPersistFile_SaveCompleted(pPf, widelink);
986 IPersistFile_Release(pPf);
987 IShellLinkA_Release(psl);
988 TRACE("shortcut %s has been created, result=%08x\n",
989 new_lnk_filepath, hres);
992 ERR("CoCreateInstance failed, hres=%08x\n", hres);
1000 RegCloseKey(HCUbasekey);
1004 /*************************************************************************
1005 * SHCreateShellFolderViewEx [SHELL32.174]
1007 * Create a new instance of the default Shell folder view object.
1011 * Failure: error value
1014 * see IShellFolder::CreateViewObject
1016 HRESULT WINAPI SHCreateShellFolderViewEx(
1017 LPCSFV psvcbi, /* [in] shelltemplate struct */
1018 IShellView **ppv) /* [out] IShellView pointer */
1023 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1024 psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
1025 psvcbi->fvm, psvcbi->psvOuter);
1027 psf = IShellView_Constructor(psvcbi->pshf);
1030 return E_OUTOFMEMORY;
1032 IShellView_AddRef(psf);
1033 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1034 IShellView_Release(psf);
1038 /*************************************************************************
1039 * SHWinHelp [SHELL32.127]
1042 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
1043 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v,w,x,z);
1046 /*************************************************************************
1047 * SHRunControlPanel [SHELL32.161]
1050 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
1051 { FIXME("0x%08x 0x%08x stub\n",x,z);
1055 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1056 /*************************************************************************
1057 * SHSetInstanceExplorer [SHELL32.176]
1060 * Sets the interface
1062 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1063 { TRACE("%p\n", lpUnknown);
1064 SHELL32_IExplorerInterface = lpUnknown;
1066 /*************************************************************************
1067 * SHGetInstanceExplorer [SHELL32.@]
1070 * gets the interface pointer of the explorer and a reference
1072 HRESULT WINAPI SHGetInstanceExplorer (IUnknown **lpUnknown)
1073 { TRACE("%p\n", lpUnknown);
1075 *lpUnknown = SHELL32_IExplorerInterface;
1077 if (!SHELL32_IExplorerInterface)
1080 IUnknown_AddRef(SHELL32_IExplorerInterface);
1083 /*************************************************************************
1084 * SHFreeUnusedLibraries [SHELL32.123]
1086 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1087 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1091 * exported by ordinal
1094 * CoFreeUnusedLibraries, SHLoadOLE
1096 void WINAPI SHFreeUnusedLibraries (void)
1099 CoFreeUnusedLibraries();
1101 /*************************************************************************
1102 * DAD_AutoScroll [SHELL32.129]
1105 BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, LPPOINT pt)
1107 FIXME("hwnd = %p %p %p\n",hwnd,samples,pt);
1110 /*************************************************************************
1111 * DAD_DragEnter [SHELL32.130]
1114 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1116 FIXME("hwnd = %p\n",hwnd);
1119 /*************************************************************************
1120 * DAD_DragEnterEx [SHELL32.131]
1123 BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p)
1125 FIXME("hwnd = %p (%d,%d)\n",hwnd,p.x,p.y);
1128 /*************************************************************************
1129 * DAD_DragMove [SHELL32.134]
1132 BOOL WINAPI DAD_DragMove(POINT p)
1134 FIXME("(%d,%d)\n",p.x,p.y);
1137 /*************************************************************************
1138 * DAD_DragLeave [SHELL32.132]
1141 BOOL WINAPI DAD_DragLeave(VOID)
1146 /*************************************************************************
1147 * DAD_SetDragImage [SHELL32.136]
1152 BOOL WINAPI DAD_SetDragImage(
1153 HIMAGELIST himlTrack,
1156 FIXME("%p %p stub\n",himlTrack, lppt);
1159 /*************************************************************************
1160 * DAD_ShowDragImage [SHELL32.137]
1165 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1167 FIXME("0x%08x stub\n",bShow);
1171 static const WCHAR szwCabLocation[] = {
1172 'S','o','f','t','w','a','r','e','\\',
1173 'M','i','c','r','o','s','o','f','t','\\',
1174 'W','i','n','d','o','w','s','\\',
1175 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1176 'E','x','p','l','o','r','e','r','\\',
1177 'C','a','b','i','n','e','t','S','t','a','t','e',0
1180 static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 };
1182 /*************************************************************************
1183 * ReadCabinetState [SHELL32.651] NT 4.0
1186 BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
1191 TRACE("%p %d\n", cs, length);
1193 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1196 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1197 if( r == ERROR_SUCCESS )
1200 r = RegQueryValueExW( hkey, szwSettings,
1201 NULL, &type, (LPBYTE)cs, (LPDWORD)&length );
1202 RegCloseKey( hkey );
1206 /* if we can't read from the registry, create default values */
1207 if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) ||
1208 (cs->cLength != length) )
1210 ERR("Initializing shell cabinet settings\n");
1211 memset(cs, 0, sizeof(*cs));
1212 cs->cLength = sizeof(*cs);
1214 cs->fFullPathTitle = FALSE;
1215 cs->fSaveLocalView = TRUE;
1216 cs->fNotShell = FALSE;
1217 cs->fSimpleDefault = TRUE;
1218 cs->fDontShowDescBar = FALSE;
1219 cs->fNewWindowMode = FALSE;
1220 cs->fShowCompColor = FALSE;
1221 cs->fDontPrettyNames = FALSE;
1222 cs->fAdminsCreateCommonGroups = TRUE;
1223 cs->fMenuEnumFilter = 96;
1229 /*************************************************************************
1230 * WriteCabinetState [SHELL32.652] NT 4.0
1233 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1243 r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0,
1244 NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
1245 if( r == ERROR_SUCCESS )
1247 r = RegSetValueExW( hkey, szwSettings, 0,
1248 REG_BINARY, (LPBYTE) cs, cs->cLength);
1250 RegCloseKey( hkey );
1253 return (r==ERROR_SUCCESS);
1256 /*************************************************************************
1257 * FileIconInit [SHELL32.660]
1260 BOOL WINAPI FileIconInit(BOOL bFullInit)
1261 { FIXME("(%s)\n", bFullInit ? "true" : "false");
1264 /*************************************************************************
1265 * IsUserAdmin [SHELL32.680] NT 4.0
1268 HRESULT WINAPI IsUserAdmin(void)
1273 /*************************************************************************
1274 * SHAllocShared [SHELL32.520]
1276 * See shlwapi.SHAllocShared
1278 HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
1280 GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
1281 return pSHAllocShared(lpvData, dwSize, dwProcId);
1284 /*************************************************************************
1285 * SHLockShared [SHELL32.521]
1287 * See shlwapi.SHLockShared
1289 LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
1291 GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
1292 return pSHLockShared(hShared, dwProcId);
1295 /*************************************************************************
1296 * SHUnlockShared [SHELL32.522]
1298 * See shlwapi.SHUnlockShared
1300 BOOL WINAPI SHUnlockShared(LPVOID lpView)
1302 GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
1303 return pSHUnlockShared(lpView);
1306 /*************************************************************************
1307 * SHFreeShared [SHELL32.523]
1309 * See shlwapi.SHFreeShared
1311 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
1313 GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
1314 return pSHFreeShared(hShared, dwProcId);
1317 /*************************************************************************
1318 * SetAppStartingCursor [SHELL32.99]
1320 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1321 { FIXME("hwnd=%p 0x%04x stub\n",u,v );
1325 /*************************************************************************
1326 * SHLoadOLE [SHELL32.151]
1328 * To reduce the memory usage of Windows 95, its shell32 contained an
1329 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1330 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1331 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1332 * would just call the Co* functions.
1334 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1335 * information from the shell32 "mini-COM" to ole32.dll.
1337 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1338 * detailed description.
1340 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1341 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1342 * hack in SHCoCreateInstance)
1344 HRESULT WINAPI SHLoadOLE(LPARAM lParam)
1345 { FIXME("0x%08lx stub\n",lParam);
1348 /*************************************************************************
1349 * DriveType [SHELL32.64]
1352 HRESULT WINAPI DriveType(DWORD u)
1353 { FIXME("0x%04x stub\n",u);
1356 /*************************************************************************
1357 * InvalidateDriveType [SHELL32.65]
1360 int WINAPI InvalidateDriveType(int u)
1361 { FIXME("0x%08x stub\n",u);
1364 /*************************************************************************
1365 * SHAbortInvokeCommand [SHELL32.198]
1368 HRESULT WINAPI SHAbortInvokeCommand(void)
1372 /*************************************************************************
1373 * SHOutOfMemoryMessageBox [SHELL32.126]
1376 int WINAPI SHOutOfMemoryMessageBox(
1381 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1384 /*************************************************************************
1385 * SHFlushClipboard [SHELL32.121]
1388 HRESULT WINAPI SHFlushClipboard(void)
1393 /*************************************************************************
1394 * SHWaitForFileToOpen [SHELL32.97]
1397 BOOL WINAPI SHWaitForFileToOpen(
1402 FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1406 /************************************************************************
1410 * first parameter seems to be a pointer (same as passed to WriteCabinetState)
1411 * second one could be a size (0x0c). The size is the same as the structure saved to
1412 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1413 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1415 HRESULT WINAPI shell32_654 (CABINETSTATE *cs, int length)
1417 TRACE("%p %d\n",cs,length);
1418 return ReadCabinetState(cs,length);
1421 /************************************************************************
1422 * RLBuildListOfPaths [SHELL32.146]
1427 DWORD WINAPI RLBuildListOfPaths (void)
1431 /************************************************************************
1432 * SHValidateUNC [SHELL32.173]
1435 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1437 FIXME("0x%08x 0x%08x 0x%08x stub\n",x,y,z);
1441 /************************************************************************
1442 * DoEnvironmentSubstA [SHELL32.@]
1444 * Replace %KEYWORD% in the str with the value of variable KEYWORD
1445 * from environment. If it is not found the %KEYWORD% is left
1446 * intact. If the buffer is too small, str is not modified.
1449 * pszString [I] '\0' terminated string with %keyword%.
1450 * [O] '\0' terminated string with %keyword% substituted.
1451 * cchString [I] size of str.
1454 * cchString length in the HIWORD;
1455 * TRUE in LOWORD if subst was successful and FALSE in other case
1457 DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
1461 FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
1462 if (pszString == NULL) /* Really return 0? */
1464 if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
1466 DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
1467 if (num && num < cchString) /* dest buffer is too small */
1470 memcpy(pszString, dst, num);
1472 HeapFree(GetProcessHeap(), 0, dst);
1474 return MAKELONG(res,cchString); /* Always cchString? */
1477 /************************************************************************
1478 * DoEnvironmentSubstW [SHELL32.@]
1480 * See DoEnvironmentSubstA.
1482 DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
1484 FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
1485 return MAKELONG(FALSE,cchString);
1488 /************************************************************************
1489 * DoEnvironmentSubst [SHELL32.53]
1491 * See DoEnvironmentSubstA.
1493 DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y)
1495 if (SHELL_OsIsUnicode())
1496 return DoEnvironmentSubstW(x, y);
1497 return DoEnvironmentSubstA(x, y);
1500 /*************************************************************************
1503 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1504 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1508 BOOL WINAPI shell32_243(DWORD a, DWORD b)
1513 /*************************************************************************
1516 DWORD WINAPI SHELL32_714(LPVOID x)
1518 FIXME("(%s)stub\n", debugstr_w(x));
1522 typedef struct _PSXA
1526 IShellPropSheetExt *pspsx[1];
1529 typedef struct _PSXA_CALL
1531 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith;
1536 } PSXA_CALL, *PPSXA_CALL;
1538 static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam)
1540 PPSXA_CALL Call = (PPSXA_CALL)lParam;
1544 if ((Call->bMultiple || !Call->bCalled) &&
1545 Call->lpfnAddReplaceWith(hpage, Call->lParam))
1547 Call->bCalled = TRUE;
1556 /*************************************************************************
1557 * SHAddFromPropSheetExtArray [SHELL32.167]
1559 UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
1563 PPSXA psxa = (PPSXA)hpsxa;
1565 TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam);
1569 ZeroMemory(&Call, sizeof(Call));
1570 Call.lpfnAddReplaceWith = lpfnAddPage;
1571 Call.lParam = lParam;
1572 Call.bMultiple = TRUE;
1574 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1575 for (i = 0; i != psxa->uiCount; i++)
1577 psxa->pspsx[i]->lpVtbl->AddPages(psxa->pspsx[i], PsxaCall, (LPARAM)&Call);
1580 return Call.uiCount;
1586 /*************************************************************************
1587 * SHCreatePropSheetExtArray [SHELL32.168]
1589 HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
1591 return SHCreatePropSheetExtArrayEx(hKey, pszSubKey, max_iface, NULL);
1594 /*************************************************************************
1595 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1597 HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, LPDATAOBJECT pDataObj)
1599 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};
1600 WCHAR szHandler[64];
1602 WCHAR szClsidHandler[39];
1607 IShellExtInit *psxi;
1608 IShellPropSheetExt *pspsx;
1609 HKEY hkBase, hkPropSheetHandlers;
1612 TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface);
1617 /* Open the registry key */
1618 lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase);
1619 if (lRet != ERROR_SUCCESS)
1622 lRet = RegOpenKeyExW(hkBase, szPropSheetSubKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkPropSheetHandlers);
1623 RegCloseKey(hkBase);
1624 if (lRet == ERROR_SUCCESS)
1626 /* Create and initialize the Property Sheet Extensions Array */
1627 psxa = (PPSXA)LocalAlloc(LMEM_FIXED, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1630 ZeroMemory(psxa, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1631 psxa->uiAllocated = max_iface;
1633 /* Enumerate all subkeys and attempt to load the shell extensions */
1637 dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]);
1638 lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL);
1639 if (lRet != ERROR_SUCCESS)
1641 if (lRet == ERROR_MORE_DATA)
1644 if (lRet == ERROR_NO_MORE_ITEMS)
1645 lRet = ERROR_SUCCESS;
1649 dwClsidSize = sizeof(szClsidHandler);
1650 if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
1652 /* Force a NULL-termination and convert the string */
1653 szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
1654 if (SUCCEEDED(SHCLSIDFromStringW(szClsidHandler, &clsid)))
1656 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1657 Only if both interfaces are supported it's a real shell extension.
1658 Then call IShellExtInit's Initialize method. */
1659 if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx)))
1661 if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi)))
1663 if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey)))
1665 /* Add the IShellPropSheetExt instance to the array */
1666 psxa->pspsx[psxa->uiCount++] = pspsx;
1670 psxi->lpVtbl->Release(psxi);
1671 pspsx->lpVtbl->Release(pspsx);
1675 pspsx->lpVtbl->Release(pspsx);
1680 } while (psxa->uiCount != psxa->uiAllocated);
1683 lRet = ERROR_NOT_ENOUGH_MEMORY;
1685 RegCloseKey(hkPropSheetHandlers);
1688 if (lRet != ERROR_SUCCESS && psxa)
1690 SHDestroyPropSheetExtArray((HPSXA)psxa);
1697 /*************************************************************************
1698 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1700 UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
1704 PPSXA psxa = (PPSXA)hpsxa;
1706 TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam);
1710 ZeroMemory(&Call, sizeof(Call));
1711 Call.lpfnAddReplaceWith = lpfnReplaceWith;
1712 Call.lParam = lParam;
1714 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1715 Each shell extension is only allowed to call the callback once during the callback. */
1716 for (i = 0; i != psxa->uiCount; i++)
1718 Call.bCalled = FALSE;
1719 psxa->pspsx[i]->lpVtbl->ReplacePage(psxa->pspsx[i], uPageID, PsxaCall, (LPARAM)&Call);
1722 return Call.uiCount;
1728 /*************************************************************************
1729 * SHDestroyPropSheetExtArray [SHELL32.169]
1731 void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
1734 PPSXA psxa = (PPSXA)hpsxa;
1736 TRACE("(%p)\n", hpsxa);
1740 for (i = 0; i != psxa->uiCount; i++)
1742 psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]);
1745 LocalFree((HLOCAL)psxa);
1749 /*************************************************************************
1750 * CIDLData_CreateFromIDArray [SHELL32.83]
1752 * Create IDataObject from PIDLs??
1754 HRESULT WINAPI CIDLData_CreateFromIDArray(
1755 LPCITEMIDLIST pidlFolder,
1757 LPCITEMIDLIST *lppidlFiles,
1758 LPDATAOBJECT *ppdataObject)
1761 HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */
1763 TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1767 for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1769 *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1770 lppidlFiles, cpidlFiles);
1771 if (*ppdataObject) return S_OK;
1772 return E_OUTOFMEMORY;
1775 /*************************************************************************
1776 * SHCreateStdEnumFmtEtc [SHELL32.74]
1781 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1783 const FORMATETC *lpFormats,
1784 LPENUMFORMATETC *ppenumFormatetc)
1786 IEnumFORMATETC *pef;
1788 TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1790 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1792 return E_OUTOFMEMORY;
1794 IEnumFORMATETC_AddRef(pef);
1795 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1796 IEnumFORMATETC_Release(pef);
1802 /*************************************************************************
1803 * SHELL32_256 (SHELL32.256)
1805 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1809 FIXME("stub %p 0x%08x %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1811 if (!lpdw0 || *lpdw0 != 0x10)
1815 LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1818 ret = E_OUTOFMEMORY;
1821 /* Initialize and return unknown lpdata structure */
1828 /*************************************************************************
1829 * SHFindFiles (SHELL32.90)
1831 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1833 FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1837 /*************************************************************************
1838 * SHUpdateImageW (SHELL32.192)
1840 * Notifies the shell that an icon in the system image list has been changed.
1843 * pszHashItem [I] Path to file that contains the icon.
1844 * iIndex [I] Zero-based index of the icon in the file.
1845 * uFlags [I] Flags determining the icon attributes. See notes.
1846 * iImageIndex [I] Index of the icon in the system image list.
1852 * uFlags can be one or more of the following flags:
1853 * GIL_NOTFILENAME - pszHashItem is not a file name.
1854 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1856 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
1858 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
1861 /*************************************************************************
1862 * SHUpdateImageA (SHELL32.191)
1864 * See SHUpdateImageW.
1866 VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex)
1868 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex);
1871 INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra)
1873 FIXME("%p - stub\n", pidlExtra);
1878 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
1880 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
1885 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
1888 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo), debugstr_a(pszDir),
1889 pszName, pfMustCopy, uFlags);
1894 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
1897 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
1898 pszName, pfMustCopy, uFlags);
1903 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
1905 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
1910 HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
1912 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1917 HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
1919 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1924 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
1926 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
1928 return SHFMT_NOFORMAT;
1931 HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1933 FIXME("%s, %p - stub\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1935 pSHQueryRBInfo->i64Size = 0;
1936 pSHQueryRBInfo->i64NumItems = 0;
1941 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1943 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1945 pSHQueryRBInfo->i64Size = 0;
1946 pSHQueryRBInfo->i64NumItems = 0;
1951 /*************************************************************************
1952 * SHSetLocalizedName (SHELL32.@)
1954 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
1956 FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
1961 /*************************************************************************
1962 * LinkWindow_RegisterClass (SHELL32.258)
1964 BOOL WINAPI LinkWindow_RegisterClass(void)
1970 /*************************************************************************
1971 * LinkWindow_UnregisterClass (SHELL32.259)
1973 BOOL WINAPI LinkWindow_UnregisterClass(void)