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
23 #include <wine/config.h>
25 #define WIN32_NO_STATUS
31 #include <wine/winternl.h>
33 #include <undocshell.h>
36 #include <commoncontrols.h>
37 #include "../shellrecyclebin/recyclebin.h"
39 #include <wine/debug.h>
40 #include <wine/unicode.h>
43 #include "shell32_main.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
46 WINE_DECLARE_DEBUG_CHANNEL(pidl
);
48 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
49 /* !!! it is in both here and comctl32undoc.c !!! */
50 typedef struct tagCREATEMRULIST
52 DWORD cbSize
; /* size of struct */
53 DWORD nMaxItems
; /* max no. of items in list */
54 DWORD dwFlags
; /* see below */
55 HKEY hKey
; /* root reg. key under which list is saved */
56 LPCSTR lpszSubKey
; /* reg. subkey */
57 int (CALLBACK
*lpfnCompare
)(LPCVOID
, LPCVOID
, DWORD
); /* item compare proc */
58 } CREATEMRULISTA
, *LPCREATEMRULISTA
;
61 #define MRUF_STRING_LIST 0 /* list will contain strings */
62 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
63 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
65 extern HANDLE WINAPI
CreateMRUListA(LPCREATEMRULISTA lpcml
);
66 extern VOID WINAPI
FreeMRUList(HANDLE hMRUList
);
67 extern INT WINAPI
AddMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
68 extern INT WINAPI
FindMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
69 extern INT WINAPI
EnumMRUListA(HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
72 /*************************************************************************
73 * ParseFieldA [internal]
75 * copies a field from a ',' delimited string
77 * first field is nField = 1
79 DWORD WINAPI
ParseFieldA(
85 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src
),nField
,dst
,len
);
87 if (!src
|| !src
[0] || !dst
|| !len
)
90 /* skip n fields delimited by ',' */
93 if (*src
=='\0') return FALSE
;
94 if (*(src
++)==',') nField
--;
97 /* copy part till the next ',' to dst */
98 while ( *src
!='\0' && *src
!=',' && (len
--)>0 ) *(dst
++)=*(src
++);
100 /* finalize the string */
106 /*************************************************************************
107 * ParseFieldW [internal]
109 * copies a field from a ',' delimited string
111 * first field is nField = 1
113 DWORD WINAPI
ParseFieldW(LPCWSTR src
, DWORD nField
, LPWSTR dst
, DWORD len
)
115 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src
), nField
, dst
, len
);
117 if (!src
|| !src
[0] || !dst
|| !len
)
120 /* skip n fields delimited by ',' */
123 if (*src
== 0x0) return FALSE
;
124 if (*src
++ == ',') nField
--;
127 /* copy part till the next ',' to dst */
128 while ( *src
!= 0x0 && *src
!= ',' && (len
--)>0 ) *(dst
++) = *(src
++);
130 /* finalize the string */
136 /*************************************************************************
137 * ParseField [SHELL32.58]
139 DWORD WINAPI
ParseFieldAW(LPCVOID src
, DWORD nField
, LPVOID dst
, DWORD len
)
141 if (SHELL_OsIsUnicode())
142 return ParseFieldW(src
, nField
, dst
, len
);
143 return ParseFieldA(src
, nField
, dst
, len
);
146 /*************************************************************************
147 * GetFileNameFromBrowse [SHELL32.63]
150 BOOL WINAPI
GetFileNameFromBrowse(
154 LPCWSTR lpstrInitialDir
,
159 typedef BOOL (WINAPI
*GetOpenFileNameProc
)(OPENFILENAMEW
*ofn
);
161 GetOpenFileNameProc pGetOpenFileNameW
;
165 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
166 hwndOwner
, debugstr_w(lpstrFile
), nMaxFile
, lpstrInitialDir
, lpstrDefExt
,
167 lpstrFilter
, lpstrTitle
);
169 hmodule
= LoadLibraryW(L
"comdlg32.dll");
170 if(!hmodule
) return FALSE
;
171 pGetOpenFileNameW
= (GetOpenFileNameProc
)GetProcAddress(hmodule
, "GetOpenFileNameW");
172 if(!pGetOpenFileNameW
)
174 FreeLibrary(hmodule
);
178 memset(&ofn
, 0, sizeof(ofn
));
180 ofn
.lStructSize
= sizeof(ofn
);
181 ofn
.hwndOwner
= hwndOwner
;
182 ofn
.lpstrFilter
= lpstrFilter
;
183 ofn
.lpstrFile
= lpstrFile
;
184 ofn
.nMaxFile
= nMaxFile
;
185 ofn
.lpstrInitialDir
= lpstrInitialDir
;
186 ofn
.lpstrTitle
= lpstrTitle
;
187 ofn
.lpstrDefExt
= lpstrDefExt
;
188 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
189 ret
= pGetOpenFileNameW(&ofn
);
191 FreeLibrary(hmodule
);
195 /*************************************************************************
196 * SHGetSetSettings [SHELL32.68]
198 VOID WINAPI
SHGetSetSettings(LPSHELLSTATE lpss
, DWORD dwMask
, BOOL bSet
)
202 FIXME("%p 0x%08x TRUE\n", lpss
, dwMask
);
206 SHGetSettings((LPSHELLFLAGSTATE
)lpss
,dwMask
);
210 /*************************************************************************
211 * SHGetSettings [SHELL32.@]
214 * the registry path are for win98 (tested)
215 * and possibly are the same in nt40
218 VOID WINAPI
SHGetSettings(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
)
222 DWORD dwDataSize
= sizeof (DWORD
);
224 TRACE("(%p 0x%08x)\n",lpsfs
,dwMask
);
226 if (RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
227 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0))
230 if ( (SSF_SHOWEXTENSIONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideFileExt", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
231 lpsfs
->fShowExtensions
= ((dwData
== 0) ? 0 : 1);
233 if ( (SSF_SHOWINFOTIP
& dwMask
) && !RegQueryValueExA(hKey
, "ShowInfoTip", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
234 lpsfs
->fShowInfoTip
= ((dwData
== 0) ? 0 : 1);
236 if ( (SSF_DONTPRETTYPATH
& dwMask
) && !RegQueryValueExA(hKey
, "DontPrettyPath", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
237 lpsfs
->fDontPrettyPath
= ((dwData
== 0) ? 0 : 1);
239 if ( (SSF_HIDEICONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideIcons", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
240 lpsfs
->fHideIcons
= ((dwData
== 0) ? 0 : 1);
242 if ( (SSF_MAPNETDRVBUTTON
& dwMask
) && !RegQueryValueExA(hKey
, "MapNetDrvBtn", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
243 lpsfs
->fMapNetDrvBtn
= ((dwData
== 0) ? 0 : 1);
245 if ( (SSF_SHOWATTRIBCOL
& dwMask
) && !RegQueryValueExA(hKey
, "ShowAttribCol", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
246 lpsfs
->fShowAttribCol
= ((dwData
== 0) ? 0 : 1);
248 if (((SSF_SHOWALLOBJECTS
| SSF_SHOWSYSFILES
) & dwMask
) && !RegQueryValueExA(hKey
, "Hidden", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
250 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
251 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
253 else if (dwData
== 1)
254 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 1;
255 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
257 else if (dwData
== 2)
258 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
259 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 1;
264 TRACE("-- 0x%04x\n", *(WORD
*)lpsfs
);
267 /*************************************************************************
268 * SHShellFolderView_Message [SHELL32.73]
270 * Send a message to an explorer cabinet window.
273 * hwndCabinet [I] The window containing the shellview to communicate with
274 * dwMessage [I] The SFVM message to send
275 * dwParam [I] Message parameter
281 * Message SFVM_REARRANGE = 1
283 * This message gets sent when a column gets clicked to instruct the
284 * shell view to re-sort the item list. dwParam identifies the column
287 LRESULT WINAPI
SHShellFolderView_Message(
292 FIXME("%p %08x %08lx stub\n",hwndCabinet
, uMessage
, lParam
);
296 /*************************************************************************
297 * RegisterShellHook [SHELL32.181]
299 * Register a shell hook.
302 * hwnd [I] Window handle
303 * dwType [I] Type of hook.
306 * Exported by ordinal
308 BOOL WINAPI
RegisterShellHook(
314 SetTaskmanWindow(hWnd
);
315 return RegisterShellHookWindow(hWnd
);
317 else if (dwType
== 0)
319 return DeregisterShellHookWindow(hWnd
);
322 ERR("Unsupported argument");
326 /*************************************************************************
327 * ShellMessageBoxW [SHELL32.182]
329 * See ShellMessageBoxA.
332 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
333 * because we can't forward to it in the .spec file since it's exported by
334 * ordinal. If you change the implementation here please update the code in
337 int ShellMessageBoxW(
345 WCHAR szText
[100],szTitle
[100];
346 LPCWSTR pszText
= szText
, pszTitle
= szTitle
;
351 __ms_va_start(args
, uType
);
352 /* wvsprintfA(buf,fmt, args); */
354 TRACE("(%p,%p,%p,%p,%08x)\n",
355 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
357 if (IS_INTRESOURCE(lpCaption
))
358 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]));
360 pszTitle
= lpCaption
;
362 if (IS_INTRESOURCE(lpText
))
363 LoadStringW(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
)/sizeof(szText
[0]));
367 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
368 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
372 ret
= MessageBoxW(hWnd
,pszTemp
,pszTitle
,uType
);
377 /*************************************************************************
378 * ShellMessageBoxA [SHELL32.183]
380 * Format and output an error message.
383 * hInstance [I] Instance handle of message creator
384 * hWnd [I] Window handle of message creator
385 * lpText [I] Resource Id of title or LPSTR
386 * lpCaption [I] Resource Id of title or LPSTR
387 * uType [I] Type of error message
390 * A return value from MessageBoxA().
393 * Exported by ordinal
395 int ShellMessageBoxA(
403 char szText
[100],szTitle
[100];
404 LPCSTR pszText
= szText
, pszTitle
= szTitle
;
409 __ms_va_start(args
, uType
);
410 /* wvsprintfA(buf,fmt, args); */
412 TRACE("(%p,%p,%p,%p,%08x)\n",
413 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
415 if (IS_INTRESOURCE(lpCaption
))
416 LoadStringA(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
));
418 pszTitle
= lpCaption
;
420 if (IS_INTRESOURCE(lpText
))
421 LoadStringA(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
));
425 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
426 pszText
, 0, 0, (LPSTR
)&pszTemp
, 0, &args
);
430 ret
= MessageBoxA(hWnd
,pszTemp
,pszTitle
,uType
);
435 /*************************************************************************
436 * SHRegisterDragDrop [SHELL32.86]
438 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
439 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
440 * for details. Under Windows 98 this function initializes the true OLE when called
441 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
443 * We follow Windows 98 behaviour.
446 * exported by ordinal
449 * RegisterDragDrop, SHLoadOLE
451 HRESULT WINAPI
SHRegisterDragDrop(
453 LPDROPTARGET pDropTarget
)
455 static BOOL ole_initialized
= FALSE
;
458 TRACE("(%p,%p)\n", hWnd
, pDropTarget
);
460 if (!ole_initialized
)
462 hr
= OleInitialize(NULL
);
465 ole_initialized
= TRUE
;
467 return RegisterDragDrop(hWnd
, pDropTarget
);
470 /*************************************************************************
471 * SHRevokeDragDrop [SHELL32.87]
473 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
474 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
475 * for details. Function removed from Windows Vista.
477 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
481 * exported by ordinal
484 * RevokeDragDrop, SHLoadOLE
486 HRESULT WINAPI
SHRevokeDragDrop(HWND hWnd
)
488 TRACE("(%p)\n", hWnd
);
489 return RevokeDragDrop(hWnd
);
492 /*************************************************************************
493 * SHDoDragDrop [SHELL32.88]
495 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
496 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
500 * exported by ordinal
503 * DoDragDrop, SHLoadOLE
505 HRESULT WINAPI
SHDoDragDrop(
507 LPDATAOBJECT lpDataObject
,
508 LPDROPSOURCE lpDropSource
,
512 FIXME("(%p %p %p 0x%08x %p):stub.\n",
513 hWnd
, lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
514 return DoDragDrop(lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
517 /*************************************************************************
518 * ArrangeWindows [SHELL32.184]
521 WORD WINAPI
ArrangeWindows(HWND hwndParent
, DWORD dwReserved
, const RECT
*lpRect
,
522 WORD cKids
, const HWND
*lpKids
)
524 /* Unimplemented in WinXP SP3 */
525 TRACE("(%p 0x%08x %p 0x%04x %p):stub.\n",
526 hwndParent
, dwReserved
, lpRect
, cKids
, lpKids
);
530 /*************************************************************************
531 * SignalFileOpen [SHELL32.103]
534 * exported by ordinal
537 SignalFileOpen (PCIDLIST_ABSOLUTE pidl
)
539 FIXME("(%p):stub.\n", pidl
);
544 /*************************************************************************
545 * SHADD_get_policy - helper function for SHAddToRecentDocs
548 * policy [IN] policy name (null termed string) to find
549 * type [OUT] ptr to DWORD to receive type
550 * buffer [OUT] ptr to area to hold data retrieved
551 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
555 * result of the SHQueryValueEx call
557 static INT
SHADD_get_policy(LPCSTR policy
, LPDWORD type
, LPVOID buffer
, LPDWORD len
)
562 /* Get the key for the policies location in the registry
564 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
565 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
566 0, KEY_READ
, &Policy_basekey
)) {
568 if (RegOpenKeyExA(HKEY_CURRENT_USER
,
569 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
570 0, KEY_READ
, &Policy_basekey
)) {
571 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
574 return ERROR_FILE_NOT_FOUND
;
578 /* Retrieve the data if it exists
580 ret
= SHQueryValueExA(Policy_basekey
, policy
, 0, type
, buffer
, len
);
581 RegCloseKey(Policy_basekey
);
586 /*************************************************************************
587 * SHADD_compare_mru - helper function for SHAddToRecentDocs
590 * data1 [IN] data being looked for
591 * data2 [IN] data in MRU
592 * cbdata [IN] length from FindMRUData call (not used)
595 * position within MRU list that data was added.
597 static INT CALLBACK
SHADD_compare_mru(LPCVOID data1
, LPCVOID data2
, DWORD cbData
)
599 return lstrcmpiA(data1
, data2
);
602 /*************************************************************************
603 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
606 * mruhandle [IN] handle for created MRU list
607 * doc_name [IN] null termed pure doc name
608 * new_lnk_name [IN] null termed path and file name for .lnk file
609 * buffer [IN/OUT] 2048 byte area to construct MRU data
610 * len [OUT] ptr to int to receive space used in buffer
613 * position within MRU list that data was added.
615 static INT
SHADD_create_add_mru_data(HANDLE mruhandle
, LPCSTR doc_name
, LPCSTR new_lnk_name
,
616 LPSTR buffer
, INT
*len
)
622 * RecentDocs MRU data structure seems to be:
623 * +0h document file name w/ terminating 0h
624 * +nh short int w/ size of remaining
625 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
626 * +n+4h 10 bytes zeros - unknown
627 * +n+eh shortcut file name w/ terminating 0h
628 * +n+e+nh 3 zero bytes - unknown
631 /* Create the MRU data structure for "RecentDocs"
634 lstrcpyA(ptr
, doc_name
);
635 ptr
+= (lstrlenA(buffer
) + 1);
636 wlen
= lstrlenA(new_lnk_name
) + 1 + 12;
637 *((short int*)ptr
) = wlen
;
638 ptr
+= 2; /* step past the length */
639 *(ptr
++) = 0x30; /* unknown reason */
640 *(ptr
++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
643 lstrcpyA(ptr
, new_lnk_name
);
644 ptr
+= (lstrlenA(new_lnk_name
) + 1);
649 /* Add the new entry into the MRU list
651 return AddMRUData(mruhandle
, buffer
, *len
);
654 /*************************************************************************
655 * SHAddToRecentDocs [SHELL32.@]
657 * Modify (add/clear) Shell's list of recently used documents.
660 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
661 * pv [IN] string or pidl, NULL clears the list
669 void WINAPI
SHAddToRecentDocs (UINT uFlags
,LPCVOID pv
)
671 /* If list is a string list lpfnCompare has the following prototype
672 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
673 * for binary lists the prototype is
674 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
675 * where cbData is the no. of bytes to compare.
676 * Need to check what return value means identical - 0?
682 CHAR doc_name
[MAX_PATH
];
683 CHAR link_dir
[MAX_PATH
];
684 CHAR new_lnk_filepath
[MAX_PATH
];
685 CHAR new_lnk_name
[MAX_PATH
];
689 HWND hwnd
= 0; /* FIXME: get real window handle */
691 DWORD data
[64], datalen
, type
;
693 TRACE("%04x %p\n", uFlags
, pv
);
696 * RecentDocs MRU data structure seems to be:
697 * +0h document file name w/ terminating 0h
698 * +nh short int w/ size of remaining
699 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
700 * +n+4h 10 bytes zeros - unknown
701 * +n+eh shortcut file name w/ terminating 0h
702 * +n+e+nh 3 zero bytes - unknown
705 /* See if we need to do anything.
708 ret
=SHADD_get_policy( "NoRecentDocsHistory", &type
, data
, &datalen
);
709 if ((ret
> 0) && (ret
!= ERROR_FILE_NOT_FOUND
)) {
710 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret
);
713 if (ret
== ERROR_SUCCESS
) {
714 if (!( (type
== REG_DWORD
) ||
715 ((type
== REG_BINARY
) && (datalen
== 4)) )) {
716 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
721 TRACE("policy value for NoRecentDocsHistory = %08x\n", data
[0]);
722 /* now test the actual policy value */
727 /* Open key to where the necessary info is
729 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
730 * and the close should be done during the _DETACH. The resulting
731 * key is stored in the DLL global data.
733 if (RegCreateKeyExA(HKEY_CURRENT_USER
,
734 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
735 0, 0, 0, KEY_READ
, 0, &HCUbasekey
, 0)) {
736 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
740 /* Get path to user's "Recent" directory
742 if(SUCCEEDED(SHGetMalloc(&ppM
))) {
743 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd
, CSIDL_RECENT
,
745 SHGetPathFromIDListA(pidl
, link_dir
);
746 IMalloc_Free(ppM
, pidl
);
751 ERR("serious issues 1\n");
753 IMalloc_Release(ppM
);
758 ERR("serious issues 2\n");
760 TRACE("Users Recent dir %s\n", link_dir
);
762 /* If no input, then go clear the lists */
764 /* clear user's Recent dir
767 /* FIXME: delete all files in "link_dir"
769 * while( more files ) {
770 * lstrcpyA(old_lnk_name, link_dir);
771 * PathAppendA(old_lnk_name, filenam);
772 * DeleteFileA(old_lnk_name);
775 FIXME("should delete all files in %s\\\n", link_dir
);
779 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
780 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
781 * and naturally it fails w/ rc=2. It should do it against
782 * HKEY_CURRENT_USER which is where it is stored, and where
783 * the MRU routines expect it!!!!
785 RegDeleteKeyA(HCUbasekey
, "RecentDocs");
786 RegCloseKey(HCUbasekey
);
790 /* Have data to add, the jobs to be done:
791 * 1. Add document to MRU list in registry "HKCU\Software\
792 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
793 * 2. Add shortcut to document in the user's Recent directory
795 * 3. Add shortcut to Start menu's Documents submenu.
798 /* Get the pure document name from the input
803 SHGetPathFromIDListA(pv
, doc_name
);
807 lstrcpynA(doc_name
, pv
, MAX_PATH
);
811 WideCharToMultiByte(CP_ACP
, 0, pv
, -1, doc_name
, MAX_PATH
, NULL
, NULL
);
815 FIXME("Unsupported flags: %u\n", uFlags
);
819 TRACE("full document name %s\n", debugstr_a(doc_name
));
822 /* check if file is a shortcut */
823 ext
= strrchr(doc_name
, '.');
824 if (!lstrcmpiA(ext
, ".lnk"))
826 WCHAR doc_nameW
[MAX_PATH
];
827 IShellLinkA
* ShellLink
;
828 int nLength
= MultiByteToWideChar(CP_ACP
, 0, doc_name
, -1, doc_nameW
, MAX_PATH
);
832 IShellLink_ConstructFromPath(doc_nameW
, &IID_IShellLinkA
, (LPVOID
*)&ShellLink
);
833 IShellLinkA_GetPath(ShellLink
, doc_name
, MAX_PATH
, NULL
, 0);
834 IShellLinkA_Release(ShellLink
);
837 ext
= strrchr(doc_name
, '.');
838 if (!lstrcmpiA(ext
, ".exe"))
840 /* executables are not added */
845 PathStripPathA(doc_name
);
846 TRACE("stripped document name %s\n", debugstr_a(doc_name
));
849 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
852 * doc_name - pure file-spec, no path
853 * link_dir - path to the user's Recent directory
854 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
856 * new_lnk_name- pure file-spec, no path for new .lnk file
858 * - path and file name of new .lnk file
860 CREATEMRULISTA mymru
;
862 INT len
, pos
, bufused
, err
;
867 CHAR old_lnk_name
[MAX_PATH
];
870 mymru
.cbSize
= sizeof(CREATEMRULISTA
);
871 mymru
.nMaxItems
= 15;
872 mymru
.dwFlags
= MRUF_BINARY_LIST
| MRUF_DELAYED_SAVE
;
873 mymru
.hKey
= HCUbasekey
;
874 mymru
.lpszSubKey
= "RecentDocs";
875 mymru
.lpfnCompare
= SHADD_compare_mru
;
876 mruhandle
= CreateMRUListA(&mymru
);
879 ERR("MRU processing failed, handle zero\n");
880 RegCloseKey(HCUbasekey
);
883 len
= lstrlenA(doc_name
);
884 pos
= FindMRUData(mruhandle
, doc_name
, len
, 0);
886 /* Now get the MRU entry that will be replaced
887 * and delete the .lnk file for it
889 if ((bufused
= EnumMRUListA(mruhandle
, (pos
== -1) ? 14 : pos
,
890 buffer
, 2048)) != -1) {
892 ptr
+= (lstrlenA(buffer
) + 1);
893 slen
= *((short int*)ptr
);
894 ptr
+= 2; /* skip the length area */
895 if (bufused
>= slen
+ (ptr
-buffer
)) {
896 /* buffer size looks good */
897 ptr
+= 12; /* get to string */
898 len
= bufused
- (ptr
-buffer
); /* get length of buf remaining */
899 if ((lstrlenA(ptr
) > 0) && (lstrlenA(ptr
) <= len
-1)) {
900 /* appears to be good string */
901 lstrcpyA(old_lnk_name
, link_dir
);
902 PathAppendA(old_lnk_name
, ptr
);
903 if (!DeleteFileA(old_lnk_name
)) {
904 if ((attr
= GetFileAttributesA(old_lnk_name
)) == INVALID_FILE_ATTRIBUTES
) {
905 if ((err
= GetLastError()) != ERROR_FILE_NOT_FOUND
) {
906 ERR("Delete for %s failed, err=%d, attr=%08x\n",
907 old_lnk_name
, err
, attr
);
910 TRACE("old .lnk file %s did not exist\n",
915 ERR("Delete for %s failed, attr=%08x\n",
920 TRACE("deleted old .lnk file %s\n", old_lnk_name
);
926 /* Create usable .lnk file name for the "Recent" directory
928 wsprintfA(new_lnk_name
, "%s.lnk", doc_name
);
929 lstrcpyA(new_lnk_filepath
, link_dir
);
930 PathAppendA(new_lnk_filepath
, new_lnk_name
);
932 olderrormode
= SetErrorMode(SEM_FAILCRITICALERRORS
);
933 while (GetFileAttributesA(new_lnk_filepath
) != INVALID_FILE_ATTRIBUTES
) {
935 wsprintfA(new_lnk_name
, "%s (%u).lnk", doc_name
, i
);
936 lstrcpyA(new_lnk_filepath
, link_dir
);
937 PathAppendA(new_lnk_filepath
, new_lnk_name
);
939 SetErrorMode(olderrormode
);
940 TRACE("new shortcut will be %s\n", new_lnk_filepath
);
942 /* Now add the new MRU entry and data
944 pos
= SHADD_create_add_mru_data(mruhandle
, doc_name
, new_lnk_name
,
946 FreeMRUList(mruhandle
);
947 TRACE("Updated MRU list, new doc is position %d\n", pos
);
950 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
953 * doc_name - pure file-spec, no path
955 * - path and file name of new .lnk file
956 * uFlags[in] - flags on call to SHAddToRecentDocs
957 * pv[in] - document path/pidl on call to SHAddToRecentDocs
959 IShellLinkA
*psl
= NULL
;
960 IPersistFile
*pPf
= NULL
;
963 WCHAR widelink
[MAX_PATH
];
967 hres
= CoCreateInstance( &CLSID_ShellLink
,
969 CLSCTX_INPROC_SERVER
,
972 if(SUCCEEDED(hres
)) {
974 hres
= IShellLinkA_QueryInterface(psl
, &IID_IPersistFile
,
978 ERR("failed QueryInterface for IPersistFile %08x\n", hres
);
982 /* Set the document path or pidl */
983 if (uFlags
== SHARD_PIDL
) {
984 hres
= IShellLinkA_SetIDList(psl
, pv
);
986 hres
= IShellLinkA_SetPath(psl
, pv
);
990 ERR("failed Set{IDList|Path} %08x\n", hres
);
994 lstrcpyA(desc
, "Shortcut to ");
995 lstrcatA(desc
, doc_name
);
996 hres
= IShellLinkA_SetDescription(psl
, desc
);
999 ERR("failed SetDescription %08x\n", hres
);
1003 MultiByteToWideChar(CP_ACP
, 0, new_lnk_filepath
, -1,
1004 widelink
, MAX_PATH
);
1005 /* create the short cut */
1006 hres
= IPersistFile_Save(pPf
, widelink
, TRUE
);
1009 ERR("failed IPersistFile::Save %08x\n", hres
);
1010 IPersistFile_Release(pPf
);
1011 IShellLinkA_Release(psl
);
1014 hres
= IPersistFile_SaveCompleted(pPf
, widelink
);
1015 IPersistFile_Release(pPf
);
1016 IShellLinkA_Release(psl
);
1017 TRACE("shortcut %s has been created, result=%08x\n",
1018 new_lnk_filepath
, hres
);
1021 ERR("CoCreateInstance failed, hres=%08x\n", hres
);
1029 RegCloseKey(HCUbasekey
);
1033 /*************************************************************************
1034 * SHCreateShellFolderViewEx [SHELL32.174]
1036 * Create a new instance of the default Shell folder view object.
1040 * Failure: error value
1043 * see IShellFolder::CreateViewObject
1045 HRESULT WINAPI
SHCreateShellFolderViewEx(
1046 LPCSFV psvcbi
, /* [in] shelltemplate struct */
1047 IShellView
**ppv
) /* [out] IShellView pointer */
1052 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1053 psvcbi
->pshf
, psvcbi
->pidl
, psvcbi
->pfnCallback
,
1054 psvcbi
->fvm
, psvcbi
->psvOuter
);
1057 hRes
= IShellView_Constructor(psvcbi
->pshf
, &psf
);
1062 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppv
);
1063 IShellView_Release(psf
);
1067 /*************************************************************************
1068 * SHWinHelp [SHELL32.127]
1071 HRESULT WINAPI
SHWinHelp (DWORD v
, DWORD w
, DWORD x
, DWORD z
)
1072 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v
,w
,x
,z
);
1075 /*************************************************************************
1076 * SHRunControlPanel [SHELL32.161]
1079 BOOL WINAPI
SHRunControlPanel (LPCWSTR commandLine
, HWND parent
)
1081 FIXME("(%s, %p): stub\n", debugstr_w(commandLine
), parent
);
1085 static LPUNKNOWN SHELL32_IExplorerInterface
=0;
1086 /*************************************************************************
1087 * SHSetInstanceExplorer [SHELL32.176]
1090 * Sets the interface
1092 VOID WINAPI
SHSetInstanceExplorer (LPUNKNOWN lpUnknown
)
1093 { TRACE("%p\n", lpUnknown
);
1094 SHELL32_IExplorerInterface
= lpUnknown
;
1096 /*************************************************************************
1097 * SHGetInstanceExplorer [SHELL32.@]
1100 * gets the interface pointer of the explorer and a reference
1102 HRESULT WINAPI
SHGetInstanceExplorer (IUnknown
**lpUnknown
)
1103 { TRACE("%p\n", lpUnknown
);
1105 *lpUnknown
= SHELL32_IExplorerInterface
;
1107 if (!SHELL32_IExplorerInterface
)
1110 IUnknown_AddRef(SHELL32_IExplorerInterface
);
1113 /*************************************************************************
1114 * SHFreeUnusedLibraries [SHELL32.123]
1116 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1117 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1121 * exported by ordinal
1124 * CoFreeUnusedLibraries, SHLoadOLE
1126 void WINAPI
SHFreeUnusedLibraries (void)
1129 CoFreeUnusedLibraries();
1131 /*************************************************************************
1132 * DAD_AutoScroll [SHELL32.129]
1135 BOOL WINAPI
DAD_AutoScroll(HWND hwnd
, AUTO_SCROLL_DATA
*samples
, const POINT
* pt
)
1137 FIXME("hwnd = %p %p %p\n",hwnd
,samples
,pt
);
1140 /*************************************************************************
1141 * DAD_DragEnter [SHELL32.130]
1144 BOOL WINAPI
DAD_DragEnter(HWND hwnd
)
1146 FIXME("hwnd = %p\n",hwnd
);
1149 /*************************************************************************
1150 * DAD_DragEnterEx [SHELL32.131]
1153 BOOL WINAPI
DAD_DragEnterEx(HWND hwnd
, POINT p
)
1155 FIXME("hwnd = %p (%d,%d)\n",hwnd
,p
.x
,p
.y
);
1158 /*************************************************************************
1159 * DAD_DragMove [SHELL32.134]
1162 BOOL WINAPI
DAD_DragMove(POINT p
)
1164 FIXME("(%d,%d)\n",p
.x
,p
.y
);
1167 /*************************************************************************
1168 * DAD_DragLeave [SHELL32.132]
1171 BOOL WINAPI
DAD_DragLeave(VOID
)
1176 /*************************************************************************
1177 * DAD_SetDragImage [SHELL32.136]
1182 BOOL WINAPI
DAD_SetDragImage(
1183 HIMAGELIST himlTrack
,
1186 FIXME("%p %p stub\n",himlTrack
, lppt
);
1189 /*************************************************************************
1190 * DAD_ShowDragImage [SHELL32.137]
1195 BOOL WINAPI
DAD_ShowDragImage(BOOL bShow
)
1197 FIXME("0x%08x stub\n",bShow
);
1201 static const WCHAR szwCabLocation
[] = {
1202 'S','o','f','t','w','a','r','e','\\',
1203 'M','i','c','r','o','s','o','f','t','\\',
1204 'W','i','n','d','o','w','s','\\',
1205 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1206 'E','x','p','l','o','r','e','r','\\',
1207 'C','a','b','i','n','e','t','S','t','a','t','e',0
1210 static const WCHAR szwSettings
[] = { 'S','e','t','t','i','n','g','s',0 };
1212 /*************************************************************************
1213 * ReadCabinetState [SHELL32.651] NT 4.0
1216 BOOL WINAPI
ReadCabinetState(CABINETSTATE
*cs
, int length
)
1221 TRACE("%p %d\n", cs
, length
);
1223 if( (cs
== NULL
) || (length
< (int)sizeof(*cs
)) )
1226 r
= RegOpenKeyW( HKEY_CURRENT_USER
, szwCabLocation
, &hkey
);
1227 if( r
== ERROR_SUCCESS
)
1230 r
= RegQueryValueExW( hkey
, szwSettings
,
1231 NULL
, &type
, (LPBYTE
)cs
, (LPDWORD
)&length
);
1232 RegCloseKey( hkey
);
1236 /* if we can't read from the registry, create default values */
1237 if ( (r
!= ERROR_SUCCESS
) || (cs
->cLength
< sizeof(*cs
)) ||
1238 (cs
->cLength
!= length
) )
1240 ERR("Initializing shell cabinet settings\n");
1241 memset(cs
, 0, sizeof(*cs
));
1242 cs
->cLength
= sizeof(*cs
);
1244 cs
->fFullPathTitle
= FALSE
;
1245 cs
->fSaveLocalView
= TRUE
;
1246 cs
->fNotShell
= FALSE
;
1247 cs
->fSimpleDefault
= TRUE
;
1248 cs
->fDontShowDescBar
= FALSE
;
1249 cs
->fNewWindowMode
= FALSE
;
1250 cs
->fShowCompColor
= FALSE
;
1251 cs
->fDontPrettyNames
= FALSE
;
1252 cs
->fAdminsCreateCommonGroups
= TRUE
;
1253 cs
->fMenuEnumFilter
= 96;
1259 /*************************************************************************
1260 * WriteCabinetState [SHELL32.652] NT 4.0
1263 BOOL WINAPI
WriteCabinetState(CABINETSTATE
*cs
)
1273 r
= RegCreateKeyExW( HKEY_CURRENT_USER
, szwCabLocation
, 0,
1274 NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
1275 if( r
== ERROR_SUCCESS
)
1277 r
= RegSetValueExW( hkey
, szwSettings
, 0,
1278 REG_BINARY
, (LPBYTE
) cs
, cs
->cLength
);
1280 RegCloseKey( hkey
);
1283 return (r
==ERROR_SUCCESS
);
1286 /*************************************************************************
1287 * FileIconInit [SHELL32.660]
1290 BOOL WINAPI
FileIconInit(BOOL bFullInit
)
1291 { FIXME("(%s)\n", bFullInit
? "true" : "false");
1295 /*************************************************************************
1296 * IsUserAnAdmin [SHELL32.680] NT 4.0
1298 * Checks whether the current user is a member of the Administrators group.
1307 BOOL WINAPI
IsUserAnAdmin(VOID
)
1309 SID_IDENTIFIER_AUTHORITY Authority
= {SECURITY_NT_AUTHORITY
};
1312 PTOKEN_GROUPS lpGroups
;
1315 BOOL bResult
= FALSE
;
1318 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &hToken
))
1323 if (!GetTokenInformation(hToken
, TokenGroups
, NULL
, 0, &dwSize
))
1325 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
1327 CloseHandle(hToken
);
1332 lpGroups
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
1333 if (lpGroups
== NULL
)
1335 CloseHandle(hToken
);
1339 if (!GetTokenInformation(hToken
, TokenGroups
, lpGroups
, dwSize
, &dwSize
))
1341 HeapFree(GetProcessHeap(), 0, lpGroups
);
1342 CloseHandle(hToken
);
1346 CloseHandle(hToken
);
1347 if (!AllocateAndInitializeSid(&Authority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
1348 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0,
1351 HeapFree(GetProcessHeap(), 0, lpGroups
);
1355 for (i
= 0; i
< lpGroups
->GroupCount
; i
++)
1357 if (EqualSid(lpSid
, lpGroups
->Groups
[i
].Sid
))
1365 HeapFree(GetProcessHeap(), 0, lpGroups
);
1369 /*************************************************************************
1370 * SetAppStartingCursor [SHELL32.99]
1372 HRESULT WINAPI
SetAppStartingCursor(HWND u
, DWORD v
)
1373 { FIXME("hwnd=%p 0x%04x stub\n",u
,v
);
1377 /*************************************************************************
1378 * SHLoadOLE [SHELL32.151]
1380 * To reduce the memory usage of Windows 95, its shell32 contained an
1381 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1382 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1383 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1384 * would just call the Co* functions.
1386 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1387 * information from the shell32 "mini-COM" to ole32.dll.
1389 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1390 * detailed description.
1392 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1393 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1394 * hack in SHCoCreateInstance)
1396 HRESULT WINAPI
SHLoadOLE(LPARAM lParam
)
1397 { FIXME("0x%08lx stub\n",lParam
);
1400 /*************************************************************************
1401 * DriveType [SHELL32.64]
1404 int WINAPI
DriveType(int DriveType
)
1406 WCHAR root
[] = L
"A:\\";
1407 root
[0] = L
'A' + DriveType
;
1408 return GetDriveTypeW(root
);
1410 /*************************************************************************
1411 * InvalidateDriveType [SHELL32.65]
1412 * Unimplemented in XP SP3
1414 int WINAPI
InvalidateDriveType(int u
)
1416 TRACE("0x%08x stub\n",u
);
1419 /*************************************************************************
1420 * SHAbortInvokeCommand [SHELL32.198]
1423 HRESULT WINAPI
SHAbortInvokeCommand(void)
1427 /*************************************************************************
1428 * SHOutOfMemoryMessageBox [SHELL32.126]
1431 int WINAPI
SHOutOfMemoryMessageBox(
1436 FIXME("%p %s 0x%08x stub\n",hwndOwner
, lpCaption
, uType
);
1439 /*************************************************************************
1440 * SHFlushClipboard [SHELL32.121]
1443 HRESULT WINAPI
SHFlushClipboard(void)
1445 return OleFlushClipboard();
1448 /*************************************************************************
1449 * SHWaitForFileToOpen [SHELL32.97]
1452 BOOL WINAPI
SHWaitForFileToOpen(
1457 FIXME("%p 0x%08x 0x%08x stub\n", pidl
, dwFlags
, dwTimeout
);
1461 /************************************************************************
1462 * RLBuildListOfPaths [SHELL32.146]
1467 DWORD WINAPI
RLBuildListOfPaths (void)
1471 /************************************************************************
1472 * SHValidateUNC [SHELL32.173]
1475 BOOL WINAPI
SHValidateUNC (HWND hwndOwner
, PWSTR pszFile
, UINT fConnect
)
1477 FIXME("(%p, %s, 0x%08x): stub\n", hwndOwner
, debugstr_w(pszFile
), fConnect
);
1481 /************************************************************************
1482 * DoEnvironmentSubstA [SHELL32.@]
1484 * See DoEnvironmentSubstW.
1486 DWORD WINAPI
DoEnvironmentSubstA(LPSTR pszString
, UINT cchString
)
1490 DWORD len
= cchString
;
1492 TRACE("(%s, %d)\n", debugstr_a(pszString
), cchString
);
1493 if (pszString
== NULL
) /* Really return 0? */
1495 if ((dst
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(CHAR
))))
1497 len
= ExpandEnvironmentStringsA(pszString
, dst
, cchString
);
1498 /* len includes the terminating 0 */
1499 if (len
&& len
< cchString
)
1502 memcpy(pszString
, dst
, len
);
1507 HeapFree(GetProcessHeap(), 0, dst
);
1509 return MAKELONG(len
, res
);
1512 /************************************************************************
1513 * DoEnvironmentSubstW [SHELL32.@]
1515 * Replace all %KEYWORD% in the string with the value of the named
1516 * environment variable. If the buffer is too small, the string is not modified.
1519 * pszString [I] '\0' terminated string with %keyword%.
1520 * [O] '\0' terminated string with %keyword% substituted.
1521 * cchString [I] size of str.
1524 * Success: The string in the buffer is updated
1526 * LOWORD: characters used in the buffer, including space for the terminating 0
1527 * Failure: buffer too small. The string is not modified.
1529 * LOWORD: provided size of the buffer in characters
1531 DWORD WINAPI
DoEnvironmentSubstW(LPWSTR pszString
, UINT cchString
)
1535 DWORD len
= cchString
;
1537 TRACE("(%s, %d)\n", debugstr_w(pszString
), cchString
);
1539 if ((cchString
< MAXLONG
) && (dst
= HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(WCHAR
))))
1541 len
= ExpandEnvironmentStringsW(pszString
, dst
, cchString
);
1542 /* len includes the terminating 0 */
1543 if (len
&& len
<= cchString
)
1546 memcpy(pszString
, dst
, len
* sizeof(WCHAR
));
1551 HeapFree(GetProcessHeap(), 0, dst
);
1553 return MAKELONG(len
, res
);
1556 /************************************************************************
1557 * DoEnvironmentSubst [SHELL32.53]
1559 * See DoEnvironmentSubstA.
1561 DWORD WINAPI
DoEnvironmentSubstAW(LPVOID x
, UINT y
)
1563 if (SHELL_OsIsUnicode())
1564 return DoEnvironmentSubstW(x
, y
);
1565 return DoEnvironmentSubstA(x
, y
);
1568 /*************************************************************************
1569 * GUIDFromStringA [SHELL32.703]
1571 BOOL WINAPI
GUIDFromStringA(LPCSTR str
, LPGUID guid
)
1573 TRACE("GUIDFromStringA() stub\n");
1577 /*************************************************************************
1578 * GUIDFromStringW [SHELL32.704]
1580 BOOL WINAPI
GUIDFromStringW(LPCWSTR str
, LPGUID guid
)
1582 UNICODE_STRING guid_str
;
1584 RtlInitUnicodeString(&guid_str
, str
);
1585 return !RtlGUIDFromString(&guid_str
, guid
);
1588 /*************************************************************************
1589 * PathIsTemporaryA [SHELL32.713]
1591 BOOL WINAPI
PathIsTemporaryA(LPSTR Str
)
1593 FIXME("(%s)stub\n", debugstr_a(Str
));
1597 /*************************************************************************
1598 * PathIsTemporaryW [SHELL32.714]
1600 BOOL WINAPI
PathIsTemporaryW(LPWSTR Str
)
1602 FIXME("(%s)stub\n", debugstr_w(Str
));
1606 typedef struct _PSXA
1610 IShellPropSheetExt
*pspsx
[1];
1613 typedef struct _PSXA_CALL
1615 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith
;
1620 } PSXA_CALL
, *PPSXA_CALL
;
1622 static BOOL CALLBACK
PsxaCall(HPROPSHEETPAGE hpage
, LPARAM lParam
)
1624 PPSXA_CALL Call
= (PPSXA_CALL
)lParam
;
1628 if ((Call
->bMultiple
|| !Call
->bCalled
) &&
1629 Call
->lpfnAddReplaceWith(hpage
, Call
->lParam
))
1631 Call
->bCalled
= TRUE
;
1640 /*************************************************************************
1641 * SHAddFromPropSheetExtArray [SHELL32.167]
1643 UINT WINAPI
SHAddFromPropSheetExtArray(HPSXA hpsxa
, LPFNADDPROPSHEETPAGE lpfnAddPage
, LPARAM lParam
)
1647 PPSXA psxa
= (PPSXA
)hpsxa
;
1649 TRACE("(%p,%p,%08lx)\n", hpsxa
, lpfnAddPage
, lParam
);
1653 ZeroMemory(&Call
, sizeof(Call
));
1654 Call
.lpfnAddReplaceWith
= lpfnAddPage
;
1655 Call
.lParam
= lParam
;
1656 Call
.bMultiple
= TRUE
;
1658 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1659 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1661 psxa
->pspsx
[i
]->lpVtbl
->AddPages(psxa
->pspsx
[i
], PsxaCall
, (LPARAM
)&Call
);
1664 return Call
.uiCount
;
1670 /*************************************************************************
1671 * SHCreatePropSheetExtArray [SHELL32.168]
1673 HPSXA WINAPI
SHCreatePropSheetExtArray(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
)
1675 return SHCreatePropSheetExtArrayEx(hKey
, pszSubKey
, max_iface
, NULL
);
1678 /*************************************************************************
1679 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1681 HPSXA WINAPI
SHCreatePropSheetExtArrayEx(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
, LPDATAOBJECT pDataObj
)
1683 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};
1684 WCHAR szHandler
[64];
1686 WCHAR szClsidHandler
[39];
1691 IShellExtInit
*psxi
;
1692 IShellPropSheetExt
*pspsx
;
1693 HKEY hkBase
, hkPropSheetHandlers
;
1696 TRACE("(%p,%s,%u)\n", hKey
, debugstr_w(pszSubKey
), max_iface
);
1701 /* Open the registry key */
1702 lRet
= RegOpenKeyW(hKey
, pszSubKey
, &hkBase
);
1703 if (lRet
!= ERROR_SUCCESS
)
1706 lRet
= RegOpenKeyExW(hkBase
, szPropSheetSubKey
, 0, KEY_ENUMERATE_SUB_KEYS
, &hkPropSheetHandlers
);
1707 RegCloseKey(hkBase
);
1708 if (lRet
== ERROR_SUCCESS
)
1710 /* Create and initialize the Property Sheet Extensions Array */
1711 psxa
= LocalAlloc(LMEM_FIXED
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1714 ZeroMemory(psxa
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1715 psxa
->uiAllocated
= max_iface
;
1717 /* Enumerate all subkeys and attempt to load the shell extensions */
1721 dwHandlerLen
= sizeof(szHandler
) / sizeof(szHandler
[0]);
1722 lRet
= RegEnumKeyExW(hkPropSheetHandlers
, dwIndex
++, szHandler
, &dwHandlerLen
, NULL
, NULL
, NULL
, NULL
);
1723 if (lRet
!= ERROR_SUCCESS
)
1725 if (lRet
== ERROR_MORE_DATA
)
1728 if (lRet
== ERROR_NO_MORE_ITEMS
)
1729 lRet
= ERROR_SUCCESS
;
1733 /* The CLSID is stored either in the key itself or in its default value. */
1734 if (FAILED(lRet
= SHCLSIDFromStringW(szHandler
, &clsid
)))
1736 dwClsidSize
= sizeof(szClsidHandler
);
1737 if (SHGetValueW(hkPropSheetHandlers
, szHandler
, NULL
, NULL
, szClsidHandler
, &dwClsidSize
) == ERROR_SUCCESS
)
1739 /* Force a NULL-termination and convert the string */
1740 szClsidHandler
[(sizeof(szClsidHandler
) / sizeof(szClsidHandler
[0])) - 1] = 0;
1741 lRet
= SHCLSIDFromStringW(szClsidHandler
, &clsid
);
1745 if (SUCCEEDED(lRet
))
1747 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1748 Only if both interfaces are supported it's a real shell extension.
1749 Then call IShellExtInit's Initialize method. */
1750 if (SUCCEEDED(CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt
, (LPVOID
*)&pspsx
)))
1752 if (SUCCEEDED(pspsx
->lpVtbl
->QueryInterface(pspsx
, &IID_IShellExtInit
, (PVOID
*)&psxi
)))
1754 if (SUCCEEDED(psxi
->lpVtbl
->Initialize(psxi
, NULL
, pDataObj
, hKey
)))
1756 /* Add the IShellPropSheetExt instance to the array */
1757 psxa
->pspsx
[psxa
->uiCount
++] = pspsx
;
1761 psxi
->lpVtbl
->Release(psxi
);
1762 pspsx
->lpVtbl
->Release(pspsx
);
1766 pspsx
->lpVtbl
->Release(pspsx
);
1770 } while (psxa
->uiCount
!= psxa
->uiAllocated
);
1773 lRet
= ERROR_NOT_ENOUGH_MEMORY
;
1775 RegCloseKey(hkPropSheetHandlers
);
1778 if (lRet
!= ERROR_SUCCESS
&& psxa
)
1780 SHDestroyPropSheetExtArray((HPSXA
)psxa
);
1787 /*************************************************************************
1788 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1790 UINT WINAPI
SHReplaceFromPropSheetExtArray(HPSXA hpsxa
, UINT uPageID
, LPFNADDPROPSHEETPAGE lpfnReplaceWith
, LPARAM lParam
)
1794 PPSXA psxa
= (PPSXA
)hpsxa
;
1796 TRACE("(%p,%u,%p,%08lx)\n", hpsxa
, uPageID
, lpfnReplaceWith
, lParam
);
1800 ZeroMemory(&Call
, sizeof(Call
));
1801 Call
.lpfnAddReplaceWith
= lpfnReplaceWith
;
1802 Call
.lParam
= lParam
;
1804 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1805 Each shell extension is only allowed to call the callback once during the callback. */
1806 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1808 Call
.bCalled
= FALSE
;
1809 psxa
->pspsx
[i
]->lpVtbl
->ReplacePage(psxa
->pspsx
[i
], uPageID
, PsxaCall
, (LPARAM
)&Call
);
1812 return Call
.uiCount
;
1818 /*************************************************************************
1819 * SHDestroyPropSheetExtArray [SHELL32.169]
1821 void WINAPI
SHDestroyPropSheetExtArray(HPSXA hpsxa
)
1824 PPSXA psxa
= (PPSXA
)hpsxa
;
1826 TRACE("(%p)\n", hpsxa
);
1830 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1832 psxa
->pspsx
[i
]->lpVtbl
->Release(psxa
->pspsx
[i
]);
1839 /*************************************************************************
1840 * CIDLData_CreateFromIDArray [SHELL32.83]
1842 * Create IDataObject from PIDLs??
1844 HRESULT WINAPI
CIDLData_CreateFromIDArray(
1845 PCIDLIST_ABSOLUTE pidlFolder
,
1847 PCUIDLIST_RELATIVE_ARRAY lppidlFiles
,
1848 LPDATAOBJECT
*ppdataObject
)
1851 HWND hwnd
= 0; /*FIXME: who should be hwnd of owner? set to desktop */
1854 TRACE("(%p, %d, %p, %p)\n", pidlFolder
, cpidlFiles
, lppidlFiles
, ppdataObject
);
1858 for (i
=0; i
<cpidlFiles
; i
++) pdump (lppidlFiles
[i
]);
1860 hResult
= IDataObject_Constructor(hwnd
, pidlFolder
, lppidlFiles
, cpidlFiles
, ppdataObject
);
1864 /*************************************************************************
1865 * SHCreateStdEnumFmtEtc [SHELL32.74]
1870 HRESULT WINAPI
SHCreateStdEnumFmtEtc(
1872 const FORMATETC
*lpFormats
,
1873 LPENUMFORMATETC
*ppenumFormatetc
)
1875 IEnumFORMATETC
*pef
;
1877 TRACE("cf=%d fe=%p pef=%p\n", cFormats
, lpFormats
, ppenumFormatetc
);
1879 hRes
= IEnumFORMATETC_Constructor(cFormats
, lpFormats
, &pef
);
1883 IEnumFORMATETC_AddRef(pef
);
1884 hRes
= IEnumFORMATETC_QueryInterface(pef
, &IID_IEnumFORMATETC
, (LPVOID
*)ppenumFormatetc
);
1885 IEnumFORMATETC_Release(pef
);
1890 /*************************************************************************
1891 * SHFindFiles (SHELL32.90)
1893 BOOL WINAPI
SHFindFiles( LPCITEMIDLIST pidlFolder
, LPCITEMIDLIST pidlSaveFile
)
1895 FIXME("%p %p\n", pidlFolder
, pidlSaveFile
);
1899 /*************************************************************************
1900 * SHUpdateImageW (SHELL32.192)
1902 * Notifies the shell that an icon in the system image list has been changed.
1905 * pszHashItem [I] Path to file that contains the icon.
1906 * iIndex [I] Zero-based index of the icon in the file.
1907 * uFlags [I] Flags determining the icon attributes. See notes.
1908 * iImageIndex [I] Index of the icon in the system image list.
1914 * uFlags can be one or more of the following flags:
1915 * GIL_NOTFILENAME - pszHashItem is not a file name.
1916 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1918 void WINAPI
SHUpdateImageW(LPCWSTR pszHashItem
, int iIndex
, UINT uFlags
, int iImageIndex
)
1920 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1923 /*************************************************************************
1924 * SHUpdateImageA (SHELL32.191)
1926 * See SHUpdateImageW.
1928 VOID WINAPI
SHUpdateImageA(LPCSTR pszHashItem
, INT iIndex
, UINT uFlags
, INT iImageIndex
)
1930 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1933 INT WINAPI
SHHandleUpdateImage(LPCITEMIDLIST pidlExtra
)
1935 FIXME("%p - stub\n", pidlExtra
);
1940 BOOL WINAPI
SHObjectProperties(HWND hwnd
, DWORD dwType
, LPCWSTR szObject
, LPCWSTR szPage
)
1942 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd
, dwType
, debugstr_w(szObject
), debugstr_w(szPage
));
1947 BOOL WINAPI
SHGetNewLinkInfoA(LPCSTR pszLinkTo
, LPCSTR pszDir
, LPSTR pszName
, BOOL
*pfMustCopy
,
1950 WCHAR wszLinkTo
[MAX_PATH
];
1951 WCHAR wszDir
[MAX_PATH
];
1952 WCHAR wszName
[MAX_PATH
];
1955 MultiByteToWideChar(CP_ACP
, 0, pszLinkTo
, -1, wszLinkTo
, MAX_PATH
);
1956 MultiByteToWideChar(CP_ACP
, 0, pszDir
, -1, wszDir
, MAX_PATH
);
1958 res
= SHGetNewLinkInfoW(wszLinkTo
, wszDir
, wszName
, pfMustCopy
, uFlags
);
1961 WideCharToMultiByte(CP_ACP
, 0, wszName
, -1, pszName
, MAX_PATH
, NULL
, NULL
);
1966 BOOL WINAPI
SHGetNewLinkInfoW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
, BOOL
*pfMustCopy
,
1969 const WCHAR
*basename
;
1970 WCHAR
*dst_basename
;
1972 static const WCHAR lnkformat
[] = {'%','s','.','l','n','k',0};
1973 static const WCHAR lnkformatnum
[] = {'%','s',' ','(','%','d',')','.','l','n','k',0};
1975 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo
), debugstr_w(pszDir
),
1976 pszName
, pfMustCopy
, uFlags
);
1978 *pfMustCopy
= FALSE
;
1980 if (uFlags
& SHGNLI_PIDL
)
1982 FIXME("SHGNLI_PIDL flag unsupported\n");
1987 FIXME("ignoring flags: 0x%08x\n", uFlags
);
1989 /* FIXME: should test if the file is a shortcut or DOS program */
1990 if (GetFileAttributesW(pszLinkTo
) == INVALID_FILE_ATTRIBUTES
)
1993 basename
= strrchrW(pszLinkTo
, '\\');
1995 basename
= basename
+1;
1997 basename
= pszLinkTo
;
1999 lstrcpynW(pszName
, pszDir
, MAX_PATH
);
2000 if (!PathAddBackslashW(pszName
))
2003 dst_basename
= pszName
+ strlenW(pszName
);
2005 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformat
, basename
);
2007 while (GetFileAttributesW(pszName
) != INVALID_FILE_ATTRIBUTES
)
2009 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformatnum
, basename
, i
);
2016 HRESULT WINAPI
SHStartNetConnectionDialog(HWND hwnd
, LPCSTR pszRemoteName
, DWORD dwType
)
2018 FIXME("%p, %s, 0x%08x - stub\n", hwnd
, debugstr_a(pszRemoteName
), dwType
);
2022 /*************************************************************************
2023 * SHSetLocalizedName (SHELL32.@)
2025 HRESULT WINAPI
SHSetLocalizedName(LPCWSTR pszPath
, LPCWSTR pszResModule
, int idsRes
)
2027 FIXME("%p, %s, %d - stub\n", pszPath
, debugstr_w(pszResModule
), idsRes
);
2032 /*************************************************************************
2033 * LinkWindow_RegisterClass (SHELL32.258)
2035 BOOL WINAPI
LinkWindow_RegisterClass(void)
2041 /*************************************************************************
2042 * LinkWindow_UnregisterClass (SHELL32.259)
2044 BOOL WINAPI
LinkWindow_UnregisterClass(DWORD dwUnused
)
2050 /*************************************************************************
2051 * SHFlushSFCache (SHELL32.526)
2053 * Notifies the shell that a user-specified special folder location has changed.
2056 * In Wine, the shell folder registry values are not cached, so this function
2059 void WINAPI
SHFlushSFCache(void)
2063 /*************************************************************************
2064 * SHGetImageList (SHELL32.727)
2066 * Returns a copy of a shell image list.
2069 * Windows XP features 4 sizes of image list, and Vista 5. Wine currently
2070 * only supports the traditional small and large image lists, so requests
2071 * for the others will currently fail.
2073 HRESULT WINAPI
SHGetImageList(int iImageList
, REFIID riid
, void **ppv
)
2075 HIMAGELIST hLarge
, hSmall
;
2077 HRESULT ret
= E_FAIL
;
2079 /* Wine currently only maintains large and small image lists */
2080 if ((iImageList
!= SHIL_LARGE
) && (iImageList
!= SHIL_SMALL
) && (iImageList
!= SHIL_SYSSMALL
))
2082 FIXME("Unsupported image list %i requested\n", iImageList
);
2086 Shell_GetImageLists(&hLarge
, &hSmall
);
2088 hNew
= ImageList_Duplicate(iImageList
== SHIL_LARGE
? hLarge
: hSmall
);
2090 /* Get the interface for the new image list */
2093 ret
= HIMAGELIST_QueryInterface(hNew
, riid
, ppv
);
2094 ImageList_Destroy(hNew
);
2097 /* Duplicating the imagelist causes the start menu items not to draw on
2098 * the first show. Was the Duplicate necessary for some reason? I believe
2099 * Windows returns the raw pointer here. */
2100 hNew
= (iImageList
== SHIL_LARGE
? hLarge
: hSmall
);
2101 ret
= IImageList2_QueryInterface((IImageList2
*) hNew
, riid
, ppv
);
2107 /*************************************************************************
2108 * SHCreateShellFolderView [SHELL32.256]
2110 * Create a new instance of the default Shell folder view object.
2114 * Failure: error value
2117 * see IShellFolder::CreateViewObject
2119 HRESULT WINAPI
SHCreateShellFolderView(const SFV_CREATE
*pcsfv
,
2126 if (!pcsfv
|| pcsfv
->cbSize
!= sizeof(*pcsfv
))
2127 return E_INVALIDARG
;
2129 TRACE("sf=%p outer=%p callback=%p\n",
2130 pcsfv
->pshf
, pcsfv
->psvOuter
, pcsfv
->psfvcb
);
2132 hRes
= IShellView_Constructor(pcsfv
->pshf
, &psf
);
2136 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppsv
);
2137 IShellView_Release(psf
);