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
33 #include <undocshell.h>
36 #include <commoncontrols.h>
37 #include <recyclebin.h>
40 #include <wine/debug.h>
41 #include <wine/unicode.h>
44 #include "shell32_main.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
47 WINE_DECLARE_DEBUG_CHANNEL(pidl
);
49 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
50 /* !!! it is in both here and comctl32undoc.c !!! */
51 typedef struct tagCREATEMRULIST
53 DWORD cbSize
; /* size of struct */
54 DWORD nMaxItems
; /* max no. of items in list */
55 DWORD dwFlags
; /* see below */
56 HKEY hKey
; /* root reg. key under which list is saved */
57 LPCSTR lpszSubKey
; /* reg. subkey */
58 int (CALLBACK
*lpfnCompare
)(LPCVOID
, LPCVOID
, DWORD
); /* item compare proc */
59 } CREATEMRULISTA
, *LPCREATEMRULISTA
;
62 #define MRUF_STRING_LIST 0 /* list will contain strings */
63 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
64 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
66 VOID WINAPI
FreeMRUList(HANDLE
);
68 EXTERN_C HANDLE WINAPI
CreateMRUListA(LPCREATEMRULISTA lpcml
);
69 EXTERN_C INT WINAPI
AddMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
70 EXTERN_C INT WINAPI
FindMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
71 EXTERN_C INT WINAPI
EnumMRUListA(HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
74 /* Get a function pointer from a DLL handle */
75 #define GET_FUNC(func, funcType, module, name, fail) \
78 if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
79 func = (funcType)GetProcAddress(SHELL32_h##module, name); \
80 if (!func) return fail; \
84 /* Function pointers for GET_FUNC macro */
85 static HMODULE SHELL32_hshlwapi
=NULL
;
87 /*************************************************************************
88 * ParseFieldA [internal]
90 * copies a field from a ',' delimited string
92 * first field is nField = 1
94 DWORD WINAPI
ParseFieldA(
100 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src
),nField
,dst
,len
);
102 if (!src
|| !src
[0] || !dst
|| !len
)
105 /* skip n fields delimited by ',' */
108 if (*src
=='\0') return FALSE
;
109 if (*(src
++)==',') nField
--;
112 /* copy part till the next ',' to dst */
113 while ( *src
!='\0' && *src
!=',' && (len
--)>0 ) *(dst
++)=*(src
++);
115 /* finalize the string */
121 /*************************************************************************
122 * ParseFieldW [internal]
124 * copies a field from a ',' delimited string
126 * first field is nField = 1
128 DWORD WINAPI
ParseFieldW(LPCWSTR src
, DWORD nField
, LPWSTR dst
, DWORD len
)
130 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src
), nField
, dst
, len
);
132 if (!src
|| !src
[0] || !dst
|| !len
)
135 /* skip n fields delimited by ',' */
138 if (*src
== 0x0) return FALSE
;
139 if (*src
++ == ',') nField
--;
142 /* copy part till the next ',' to dst */
143 while ( *src
!= 0x0 && *src
!= ',' && (len
--)>0 ) *(dst
++) = *(src
++);
145 /* finalize the string */
151 /*************************************************************************
152 * ParseField [SHELL32.58]
154 EXTERN_C DWORD WINAPI
ParseFieldAW(LPCVOID src
, DWORD nField
, LPVOID dst
, DWORD len
)
156 if (SHELL_OsIsUnicode())
157 return ParseFieldW((LPCWSTR
)src
, nField
, (LPWSTR
)dst
, len
);
158 return ParseFieldA((LPCSTR
)src
, nField
, (LPSTR
)dst
, len
);
161 /*************************************************************************
162 * GetFileNameFromBrowse [SHELL32.63]
165 BOOL WINAPI
GetFileNameFromBrowse(
169 LPCWSTR lpstrInitialDir
,
174 typedef BOOL (WINAPI
*GetOpenFileNameProc
)(OPENFILENAMEW
*ofn
);
176 GetOpenFileNameProc pGetOpenFileNameW
;
180 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
181 hwndOwner
, debugstr_w(lpstrFile
), nMaxFile
, lpstrInitialDir
, lpstrDefExt
,
182 lpstrFilter
, lpstrTitle
);
184 hmodule
= LoadLibraryW(L
"comdlg32.dll");
185 if(!hmodule
) return FALSE
;
186 pGetOpenFileNameW
= (GetOpenFileNameProc
)GetProcAddress(hmodule
, "GetOpenFileNameW");
187 if(!pGetOpenFileNameW
)
189 FreeLibrary(hmodule
);
193 memset(&ofn
, 0, sizeof(ofn
));
195 ofn
.lStructSize
= sizeof(ofn
);
196 ofn
.hwndOwner
= hwndOwner
;
197 ofn
.lpstrFilter
= lpstrFilter
;
198 ofn
.lpstrFile
= lpstrFile
;
199 ofn
.nMaxFile
= nMaxFile
;
200 ofn
.lpstrInitialDir
= lpstrInitialDir
;
201 ofn
.lpstrTitle
= lpstrTitle
;
202 ofn
.lpstrDefExt
= lpstrDefExt
;
203 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
204 ret
= pGetOpenFileNameW(&ofn
);
206 FreeLibrary(hmodule
);
210 /*************************************************************************
211 * SHGetSetSettings [SHELL32.68]
213 EXTERN_C VOID WINAPI
SHGetSetSettings(LPSHELLSTATE lpss
, DWORD dwMask
, BOOL bSet
)
217 FIXME("%p 0x%08x TRUE\n", lpss
, dwMask
);
221 SHGetSettings((LPSHELLFLAGSTATE
)lpss
,dwMask
);
225 /*************************************************************************
226 * SHGetSettings [SHELL32.@]
229 * the registry path are for win98 (tested)
230 * and possibly are the same in nt40
233 EXTERN_C VOID WINAPI
SHGetSettings(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
)
237 DWORD dwDataSize
= sizeof (DWORD
);
239 TRACE("(%p 0x%08x)\n",lpsfs
,dwMask
);
241 if (RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
242 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0))
245 if ( (SSF_SHOWEXTENSIONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideFileExt", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
246 lpsfs
->fShowExtensions
= ((dwData
== 0) ? 0 : 1);
248 if ( (SSF_SHOWINFOTIP
& dwMask
) && !RegQueryValueExA(hKey
, "ShowInfoTip", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
249 lpsfs
->fShowInfoTip
= ((dwData
== 0) ? 0 : 1);
251 if ( (SSF_DONTPRETTYPATH
& dwMask
) && !RegQueryValueExA(hKey
, "DontPrettyPath", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
252 lpsfs
->fDontPrettyPath
= ((dwData
== 0) ? 0 : 1);
254 if ( (SSF_HIDEICONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideIcons", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
255 lpsfs
->fHideIcons
= ((dwData
== 0) ? 0 : 1);
257 if ( (SSF_MAPNETDRVBUTTON
& dwMask
) && !RegQueryValueExA(hKey
, "MapNetDrvBtn", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
258 lpsfs
->fMapNetDrvBtn
= ((dwData
== 0) ? 0 : 1);
260 if ( (SSF_SHOWATTRIBCOL
& dwMask
) && !RegQueryValueExA(hKey
, "ShowAttribCol", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
261 lpsfs
->fShowAttribCol
= ((dwData
== 0) ? 0 : 1);
263 if (((SSF_SHOWALLOBJECTS
| SSF_SHOWSYSFILES
) & dwMask
) && !RegQueryValueExA(hKey
, "Hidden", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
265 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
266 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
268 else if (dwData
== 1)
269 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 1;
270 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
272 else if (dwData
== 2)
273 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
274 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 1;
279 TRACE("-- 0x%04x\n", *(WORD
*)lpsfs
);
282 /*************************************************************************
283 * SHShellFolderView_Message [SHELL32.73]
285 * Send a message to an explorer cabinet window.
288 * hwndCabinet [I] The window containing the shellview to communicate with
289 * dwMessage [I] The SFVM message to send
290 * dwParam [I] Message parameter
296 * Message SFVM_REARRANGE = 1
298 * This message gets sent when a column gets clicked to instruct the
299 * shell view to re-sort the item list. dwParam identifies the column
302 LRESULT WINAPI
SHShellFolderView_Message(
307 FIXME("%p %08x %08lx stub\n",hwndCabinet
, uMessage
, lParam
);
311 /*************************************************************************
312 * RegisterShellHook [SHELL32.181]
314 * Register a shell hook.
317 * hwnd [I] Window handle
318 * dwType [I] Type of hook.
321 * Exported by ordinal
323 BOOL WINAPI
RegisterShellHook(
328 return RegisterShellHookWindow(hWnd
);
329 else if (dwType
== 0)
330 return DeregisterShellHookWindow(hWnd
);
332 ERR("Unsupported argument");
336 /*************************************************************************
337 * ShellMessageBoxW [SHELL32.182]
339 * See ShellMessageBoxA.
342 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
343 * because we can't forward to it in the .spec file since it's exported by
344 * ordinal. If you change the implementation here please update the code in
347 EXTERN_C
int ShellMessageBoxW(
355 WCHAR szText
[100],szTitle
[100];
356 LPCWSTR pszText
= szText
, pszTitle
= szTitle
;
361 va_start(args
, uType
);
362 /* wvsprintfA(buf,fmt, args); */
364 TRACE("(%p,%p,%p,%p,%08x)\n",
365 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
367 if (IS_INTRESOURCE(lpCaption
))
368 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]));
370 pszTitle
= lpCaption
;
372 if (IS_INTRESOURCE(lpText
))
373 LoadStringW(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
)/sizeof(szText
[0]));
377 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
378 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
382 ret
= MessageBoxW(hWnd
,pszTemp
,pszTitle
,uType
);
387 /*************************************************************************
388 * ShellMessageBoxA [SHELL32.183]
390 * Format and output an error message.
393 * hInstance [I] Instance handle of message creator
394 * hWnd [I] Window handle of message creator
395 * lpText [I] Resource Id of title or LPSTR
396 * lpCaption [I] Resource Id of title or LPSTR
397 * uType [I] Type of error message
400 * A return value from MessageBoxA().
403 * Exported by ordinal
405 EXTERN_C
int ShellMessageBoxA(
413 char szText
[100],szTitle
[100];
414 LPCSTR pszText
= szText
, pszTitle
= szTitle
;
419 va_start(args
, uType
);
420 /* wvsprintfA(buf,fmt, args); */
422 TRACE("(%p,%p,%p,%p,%08x)\n",
423 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
425 if (IS_INTRESOURCE(lpCaption
))
426 LoadStringA(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
));
428 pszTitle
= lpCaption
;
430 if (IS_INTRESOURCE(lpText
))
431 LoadStringA(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
));
435 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
436 pszText
, 0, 0, (LPSTR
)&pszTemp
, 0, &args
);
440 ret
= MessageBoxA(hWnd
,pszTemp
,pszTitle
,uType
);
445 /*************************************************************************
446 * SHRegisterDragDrop [SHELL32.86]
448 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
449 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
450 * for details. Under Windows 98 this function initializes the true OLE when called
451 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
453 * We follow Windows 98 behaviour.
456 * exported by ordinal
459 * RegisterDragDrop, SHLoadOLE
461 HRESULT WINAPI
SHRegisterDragDrop(
463 LPDROPTARGET pDropTarget
)
465 static BOOL ole_initialized
= FALSE
;
468 TRACE("(%p,%p)\n", hWnd
, pDropTarget
);
470 if (!ole_initialized
)
472 hr
= OleInitialize(NULL
);
475 ole_initialized
= TRUE
;
477 return RegisterDragDrop(hWnd
, pDropTarget
);
480 /*************************************************************************
481 * SHRevokeDragDrop [SHELL32.87]
483 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
484 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
485 * for details. Function removed from Windows Vista.
487 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
491 * exported by ordinal
494 * RevokeDragDrop, SHLoadOLE
496 HRESULT WINAPI
SHRevokeDragDrop(HWND hWnd
)
498 TRACE("(%p)\n", hWnd
);
499 return RevokeDragDrop(hWnd
);
502 /*************************************************************************
503 * SHDoDragDrop [SHELL32.88]
505 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
506 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
510 * exported by ordinal
513 * DoDragDrop, SHLoadOLE
515 HRESULT WINAPI
SHDoDragDrop(
517 IDataObject
* lpDataObject
,
518 LPDROPSOURCE lpDropSource
,
522 FIXME("(%p %p %p 0x%08x %p):stub.\n",
523 hWnd
, lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
524 return DoDragDrop(lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
527 /*************************************************************************
528 * ArrangeWindows [SHELL32.184]
531 WORD WINAPI
ArrangeWindows(
538 /* Unimplemented in WinXP SP3 */
539 TRACE("(%p 0x%08x %p 0x%04x %p):stub.\n",
540 hwndParent
, dwReserved
, lpRect
, cKids
, lpKids
);
544 /*************************************************************************
545 * SignalFileOpen [SHELL32.103]
548 * exported by ordinal
551 SignalFileOpen (LPCITEMIDLIST pidl
)
553 FIXME("(0x%08x):stub.\n", pidl
);
558 /*************************************************************************
559 * SHADD_get_policy - helper function for SHAddToRecentDocs
562 * policy [IN] policy name (null termed string) to find
563 * type [OUT] ptr to DWORD to receive type
564 * buffer [OUT] ptr to area to hold data retrieved
565 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
569 * result of the SHQueryValueEx call
571 static INT
SHADD_get_policy(LPCSTR policy
, LPDWORD type
, LPVOID buffer
, LPDWORD len
)
576 /* Get the key for the policies location in the registry
578 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
579 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
580 0, KEY_READ
, &Policy_basekey
)) {
582 if (RegOpenKeyExA(HKEY_CURRENT_USER
,
583 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
584 0, KEY_READ
, &Policy_basekey
)) {
585 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
588 return ERROR_FILE_NOT_FOUND
;
592 /* Retrieve the data if it exists
594 ret
= SHQueryValueExA(Policy_basekey
, policy
, 0, type
, buffer
, len
);
595 RegCloseKey(Policy_basekey
);
600 /*************************************************************************
601 * SHADD_compare_mru - helper function for SHAddToRecentDocs
604 * data1 [IN] data being looked for
605 * data2 [IN] data in MRU
606 * cbdata [IN] length from FindMRUData call (not used)
609 * position within MRU list that data was added.
611 static INT CALLBACK
SHADD_compare_mru(LPCVOID data1
, LPCVOID data2
, DWORD cbData
)
613 return lstrcmpiA((LPCSTR
)data1
, (LPCSTR
)data2
);
616 /*************************************************************************
617 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
620 * mruhandle [IN] handle for created MRU list
621 * doc_name [IN] null termed pure doc name
622 * new_lnk_name [IN] null termed path and file name for .lnk file
623 * buffer [IN/OUT] 2048 byte area to construct MRU data
624 * len [OUT] ptr to int to receive space used in buffer
627 * position within MRU list that data was added.
629 static INT
SHADD_create_add_mru_data(HANDLE mruhandle
, LPCSTR doc_name
, LPCSTR new_lnk_name
,
630 LPSTR buffer
, INT
*len
)
636 * RecentDocs MRU data structure seems to be:
637 * +0h document file name w/ terminating 0h
638 * +nh short int w/ size of remaining
639 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
640 * +n+4h 10 bytes zeros - unknown
641 * +n+eh shortcut file name w/ terminating 0h
642 * +n+e+nh 3 zero bytes - unknown
645 /* Create the MRU data structure for "RecentDocs"
648 lstrcpyA(ptr
, doc_name
);
649 ptr
+= (lstrlenA(buffer
) + 1);
650 wlen
= lstrlenA(new_lnk_name
) + 1 + 12;
651 *((short int*)ptr
) = wlen
;
652 ptr
+= 2; /* step past the length */
653 *(ptr
++) = 0x30; /* unknown reason */
654 *(ptr
++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
657 lstrcpyA(ptr
, new_lnk_name
);
658 ptr
+= (lstrlenA(new_lnk_name
) + 1);
663 /* Add the new entry into the MRU list
665 return AddMRUData(mruhandle
, buffer
, *len
);
668 /*************************************************************************
669 * SHAddToRecentDocs [SHELL32.@]
671 * Modify (add/clear) Shell's list of recently used documents.
674 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
675 * pv [IN] string or pidl, NULL clears the list
683 void WINAPI
SHAddToRecentDocs (UINT uFlags
,LPCVOID pv
)
685 /* If list is a string list lpfnCompare has the following prototype
686 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
687 * for binary lists the prototype is
688 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
689 * where cbData is the no. of bytes to compare.
690 * Need to check what return value means identical - 0?
696 CHAR doc_name
[MAX_PATH
];
697 CHAR link_dir
[MAX_PATH
];
698 CHAR new_lnk_filepath
[MAX_PATH
];
699 CHAR new_lnk_name
[MAX_PATH
];
703 HWND hwnd
= 0; /* FIXME: get real window handle */
705 DWORD data
[64], datalen
, type
;
707 TRACE("%04x %p\n", uFlags
, pv
);
710 * RecentDocs MRU data structure seems to be:
711 * +0h document file name w/ terminating 0h
712 * +nh short int w/ size of remaining
713 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
714 * +n+4h 10 bytes zeros - unknown
715 * +n+eh shortcut file name w/ terminating 0h
716 * +n+e+nh 3 zero bytes - unknown
719 /* See if we need to do anything.
722 ret
=SHADD_get_policy( "NoRecentDocsHistory", &type
, data
, &datalen
);
723 if ((ret
> 0) && (ret
!= ERROR_FILE_NOT_FOUND
)) {
724 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret
);
727 if (ret
== ERROR_SUCCESS
) {
728 if (!( (type
== REG_DWORD
) ||
729 ((type
== REG_BINARY
) && (datalen
== 4)) )) {
730 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
735 TRACE("policy value for NoRecentDocsHistory = %08x\n", data
[0]);
736 /* now test the actual policy value */
741 /* Open key to where the necessary info is
743 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
744 * and the close should be done during the _DETACH. The resulting
745 * key is stored in the DLL global data.
747 if (RegCreateKeyExA(HKEY_CURRENT_USER
,
748 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
749 0, 0, 0, KEY_READ
, 0, &HCUbasekey
, 0)) {
750 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
754 /* Get path to user's "Recent" directory
756 if(SUCCEEDED(SHGetMalloc(&ppM
))) {
757 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd
, CSIDL_RECENT
,
759 SHGetPathFromIDListA(pidl
, link_dir
);
760 IMalloc_Free(ppM
, pidl
);
765 ERR("serious issues 1\n");
771 ERR("serious issues 2\n");
773 TRACE("Users Recent dir %s\n", link_dir
);
775 /* If no input, then go clear the lists */
777 /* clear user's Recent dir
780 /* FIXME: delete all files in "link_dir"
782 * while( more files ) {
783 * lstrcpyA(old_lnk_name, link_dir);
784 * PathAppendA(old_lnk_name, filenam);
785 * DeleteFileA(old_lnk_name);
788 FIXME("should delete all files in %s\\\n", link_dir
);
792 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
793 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
794 * and naturally it fails w/ rc=2. It should do it against
795 * HKEY_CURRENT_USER which is where it is stored, and where
796 * the MRU routines expect it!!!!
798 RegDeleteKeyA(HCUbasekey
, "RecentDocs");
799 RegCloseKey(HCUbasekey
);
803 /* Have data to add, the jobs to be done:
804 * 1. Add document to MRU list in registry "HKCU\Software\
805 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
806 * 2. Add shortcut to document in the user's Recent directory
808 * 3. Add shortcut to Start menu's Documents submenu.
811 /* Get the pure document name from the input
816 SHGetPathFromIDListA((LPCITEMIDLIST
)pv
, doc_name
);
820 lstrcpynA(doc_name
, (LPCSTR
)pv
, MAX_PATH
);
824 WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)pv
, -1, doc_name
, MAX_PATH
, NULL
, NULL
);
828 FIXME("Unsupported flags: %u\n", uFlags
);
832 TRACE("full document name %s\n", debugstr_a(doc_name
));
834 /* check if file is a shortcut */
835 ext
= strrchr(doc_name
, '.');
836 if (!lstrcmpiA(ext
, ".lnk"))
838 IShellLinkA
* ShellLink
;
839 IShellLink_ConstructFromFile(NULL
, &IID_IShellLinkA
, (LPCITEMIDLIST
)SHSimpleIDListFromPathA(doc_name
), (LPVOID
*)&ShellLink
);
840 IShellLinkA_GetPath(ShellLink
, doc_name
, MAX_PATH
, NULL
, 0);
841 IShellLinkA_Release(ShellLink
);
844 ext
= strrchr(doc_name
, '.');
845 if (!lstrcmpiA(ext
, ".exe"))
847 /* executables are not added */
851 PathStripPathA(doc_name
);
852 TRACE("stripped document name %s\n", debugstr_a(doc_name
));
855 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
858 * doc_name - pure file-spec, no path
859 * link_dir - path to the user's Recent directory
860 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
862 * new_lnk_name- pure file-spec, no path for new .lnk file
864 * - path and file name of new .lnk file
866 CREATEMRULISTA mymru
;
868 INT len
, pos
, bufused
, err
;
873 CHAR old_lnk_name
[MAX_PATH
];
876 mymru
.cbSize
= sizeof(CREATEMRULISTA
);
877 mymru
.nMaxItems
= 15;
878 mymru
.dwFlags
= MRUF_BINARY_LIST
| MRUF_DELAYED_SAVE
;
879 mymru
.hKey
= HCUbasekey
;
880 mymru
.lpszSubKey
= "RecentDocs";
881 mymru
.lpfnCompare
= SHADD_compare_mru
;
882 mruhandle
= CreateMRUListA(&mymru
);
885 ERR("MRU processing failed, handle zero\n");
886 RegCloseKey(HCUbasekey
);
889 len
= lstrlenA(doc_name
);
890 pos
= FindMRUData(mruhandle
, doc_name
, len
, 0);
892 /* Now get the MRU entry that will be replaced
893 * and delete the .lnk file for it
895 if ((bufused
= EnumMRUListA(mruhandle
, (pos
== -1) ? 14 : pos
,
896 buffer
, 2048)) != -1) {
898 ptr
+= (lstrlenA(buffer
) + 1);
899 slen
= *((short int*)ptr
);
900 ptr
+= 2; /* skip the length area */
901 if (bufused
>= slen
+ (ptr
-buffer
)) {
902 /* buffer size looks good */
903 ptr
+= 12; /* get to string */
904 len
= bufused
- (ptr
-buffer
); /* get length of buf remaining */
905 if ((lstrlenA(ptr
) > 0) && (lstrlenA(ptr
) <= len
-1)) {
906 /* appears to be good string */
907 lstrcpyA(old_lnk_name
, link_dir
);
908 PathAppendA(old_lnk_name
, ptr
);
909 if (!DeleteFileA(old_lnk_name
)) {
910 if ((attr
= GetFileAttributesA(old_lnk_name
)) == INVALID_FILE_ATTRIBUTES
) {
911 if ((err
= GetLastError()) != ERROR_FILE_NOT_FOUND
) {
912 ERR("Delete for %s failed, err=%d, attr=%08x\n",
913 old_lnk_name
, err
, attr
);
916 TRACE("old .lnk file %s did not exist\n",
921 ERR("Delete for %s failed, attr=%08x\n",
926 TRACE("deleted old .lnk file %s\n", old_lnk_name
);
932 /* Create usable .lnk file name for the "Recent" directory
934 wsprintfA(new_lnk_name
, "%s.lnk", doc_name
);
935 lstrcpyA(new_lnk_filepath
, link_dir
);
936 PathAppendA(new_lnk_filepath
, new_lnk_name
);
938 olderrormode
= SetErrorMode(SEM_FAILCRITICALERRORS
);
939 while (GetFileAttributesA(new_lnk_filepath
) != INVALID_FILE_ATTRIBUTES
) {
941 wsprintfA(new_lnk_name
, "%s (%u).lnk", doc_name
, i
);
942 lstrcpyA(new_lnk_filepath
, link_dir
);
943 PathAppendA(new_lnk_filepath
, new_lnk_name
);
945 SetErrorMode(olderrormode
);
946 TRACE("new shortcut will be %s\n", new_lnk_filepath
);
948 /* Now add the new MRU entry and data
950 pos
= SHADD_create_add_mru_data(mruhandle
, doc_name
, new_lnk_name
,
952 FreeMRUList(mruhandle
);
953 TRACE("Updated MRU list, new doc is position %d\n", pos
);
956 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
959 * doc_name - pure file-spec, no path
961 * - path and file name of new .lnk file
962 * uFlags[in] - flags on call to SHAddToRecentDocs
963 * pv[in] - document path/pidl on call to SHAddToRecentDocs
965 IShellLinkA
*psl
= NULL
;
966 IPersistFile
*pPf
= NULL
;
969 WCHAR widelink
[MAX_PATH
];
973 hres
= CoCreateInstance(&CLSID_ShellLink
,
975 CLSCTX_INPROC_SERVER
,
978 if(SUCCEEDED(hres
)) {
980 hres
= IShellLinkA_QueryInterface(psl
, &IID_IPersistFile
, (LPVOID
*)&pPf
);
983 ERR("failed QueryInterface for IPersistFile %08x\n", hres
);
987 /* Set the document path or pidl */
988 if (uFlags
== SHARD_PIDL
) {
989 hres
= IShellLinkA_SetIDList(psl
, pv
);
991 hres
= IShellLinkA_SetPath(psl
, pv
);
995 ERR("failed Set{IDList|Path} %08x\n", hres
);
999 lstrcpyA(desc
, "Shortcut to ");
1000 lstrcatA(desc
, doc_name
);
1001 hres
= IShellLinkA_SetDescription(psl
, desc
);
1004 ERR("failed SetDescription %08x\n", hres
);
1008 MultiByteToWideChar(CP_ACP
, 0, new_lnk_filepath
, -1,
1009 widelink
, MAX_PATH
);
1010 /* create the short cut */
1011 hres
= IPersistFile_Save(pPf
, widelink
, TRUE
);
1014 ERR("failed IPersistFile::Save %08x\n", hres
);
1017 hres
= IPersistFile_SaveCompleted(pPf
, widelink
);
1018 TRACE("shortcut %s has been created, result=%08x\n",
1019 new_lnk_filepath
, hres
);
1022 ERR("CoCreateInstance failed, hres=%08x\n", hres
);
1030 RegCloseKey(HCUbasekey
);
1034 /*************************************************************************
1035 * SHCreateShellFolderViewEx [SHELL32.174]
1037 * Create a new instance of the default Shell folder view object.
1041 * Failure: error value
1044 * see IShellFolder::CreateViewObject
1046 HRESULT WINAPI
SHCreateShellFolderViewEx(
1047 LPCSFV psvcbi
, /* [in] shelltemplate struct */
1048 IShellView
**ppv
) /* [out] IShellView pointer */
1053 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1054 psvcbi
->pshf
, psvcbi
->pidl
, psvcbi
->pfnCallback
,
1055 psvcbi
->fvm
, psvcbi
->psvOuter
);
1058 hRes
= IShellView_Constructor(psvcbi
->pshf
, &psf
);
1062 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppv
);
1066 /*************************************************************************
1067 * SHWinHelp [SHELL32.127]
1070 EXTERN_C HRESULT WINAPI
SHWinHelp (DWORD v
, DWORD w
, DWORD x
, DWORD z
)
1071 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v
,w
,x
,z
);
1074 /*************************************************************************
1075 * SHRunControlPanel [SHELL32.161]
1078 EXTERN_C BOOL WINAPI
SHRunControlPanel (LPCWSTR lpcszCmdLine
, HWND hwndMsgParent
)
1080 FIXME("0x%08x 0x%08x stub\n",lpcszCmdLine
,hwndMsgParent
);
1084 static IUnknown
* SHELL32_IExplorerInterface
=0;
1085 /*************************************************************************
1086 * SHSetInstanceExplorer [SHELL32.176]
1089 * Sets the interface
1091 VOID WINAPI
SHSetInstanceExplorer (IUnknown
* lpUnknown
)
1092 { TRACE("%p\n", lpUnknown
);
1093 SHELL32_IExplorerInterface
= lpUnknown
;
1095 /*************************************************************************
1096 * SHGetInstanceExplorer [SHELL32.@]
1099 * gets the interface pointer of the explorer and a reference
1101 HRESULT WINAPI
SHGetInstanceExplorer (IUnknown
**lpUnknown
)
1102 { TRACE("%p\n", lpUnknown
);
1104 *lpUnknown
= SHELL32_IExplorerInterface
;
1106 if (!SHELL32_IExplorerInterface
)
1109 IUnknown_AddRef(SHELL32_IExplorerInterface
);
1112 /*************************************************************************
1113 * SHFreeUnusedLibraries [SHELL32.123]
1115 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1116 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1120 * exported by ordinal
1123 * CoFreeUnusedLibraries, SHLoadOLE
1125 void WINAPI
SHFreeUnusedLibraries (void)
1128 CoFreeUnusedLibraries();
1130 /*************************************************************************
1131 * DAD_AutoScroll [SHELL32.129]
1134 BOOL WINAPI
DAD_AutoScroll(HWND hwnd
, AUTO_SCROLL_DATA
*samples
, const POINT
* pt
)
1136 FIXME("hwnd = %p %p %p\n",hwnd
,samples
,pt
);
1139 /*************************************************************************
1140 * DAD_DragEnter [SHELL32.130]
1143 BOOL WINAPI
DAD_DragEnter(HWND hwnd
)
1145 FIXME("hwnd = %p\n",hwnd
);
1148 /*************************************************************************
1149 * DAD_DragEnterEx [SHELL32.131]
1152 BOOL WINAPI
DAD_DragEnterEx(HWND hwnd
, POINT p
)
1154 FIXME("hwnd = %p (%d,%d)\n",hwnd
,p
.x
,p
.y
);
1157 /*************************************************************************
1158 * DAD_DragMove [SHELL32.134]
1161 BOOL WINAPI
DAD_DragMove(POINT p
)
1163 FIXME("(%d,%d)\n",p
.x
,p
.y
);
1166 /*************************************************************************
1167 * DAD_DragLeave [SHELL32.132]
1170 BOOL WINAPI
DAD_DragLeave(VOID
)
1175 /*************************************************************************
1176 * DAD_SetDragImage [SHELL32.136]
1181 BOOL WINAPI
DAD_SetDragImage(
1182 HIMAGELIST himlTrack
,
1185 FIXME("%p %p stub\n",himlTrack
, lppt
);
1188 /*************************************************************************
1189 * DAD_ShowDragImage [SHELL32.137]
1194 BOOL WINAPI
DAD_ShowDragImage(BOOL bShow
)
1196 FIXME("0x%08x stub\n",bShow
);
1200 static const WCHAR szwCabLocation
[] = {
1201 'S','o','f','t','w','a','r','e','\\',
1202 'M','i','c','r','o','s','o','f','t','\\',
1203 'W','i','n','d','o','w','s','\\',
1204 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1205 'E','x','p','l','o','r','e','r','\\',
1206 'C','a','b','i','n','e','t','S','t','a','t','e',0
1209 static const WCHAR szwSettings
[] = { 'S','e','t','t','i','n','g','s',0 };
1211 /*************************************************************************
1212 * ReadCabinetState [SHELL32.651] NT 4.0
1215 BOOL WINAPI
ReadCabinetState(CABINETSTATE
*cs
, int length
)
1220 TRACE("%p %d\n", cs
, length
);
1222 if( (cs
== NULL
) || (length
< (int)sizeof(*cs
)) )
1225 r
= RegOpenKeyW( HKEY_CURRENT_USER
, szwCabLocation
, &hkey
);
1226 if( r
== ERROR_SUCCESS
)
1229 r
= RegQueryValueExW( hkey
, szwSettings
,
1230 NULL
, &type
, (LPBYTE
)cs
, (LPDWORD
)&length
);
1231 RegCloseKey( hkey
);
1235 /* if we can't read from the registry, create default values */
1236 if ( (r
!= ERROR_SUCCESS
) || (cs
->cLength
< sizeof(*cs
)) ||
1237 (cs
->cLength
!= length
) )
1239 ERR("Initializing shell cabinet settings\n");
1240 memset(cs
, 0, sizeof(*cs
));
1241 cs
->cLength
= sizeof(*cs
);
1243 cs
->fFullPathTitle
= FALSE
;
1244 cs
->fSaveLocalView
= TRUE
;
1245 cs
->fNotShell
= FALSE
;
1246 cs
->fSimpleDefault
= TRUE
;
1247 cs
->fDontShowDescBar
= FALSE
;
1248 cs
->fNewWindowMode
= FALSE
;
1249 cs
->fShowCompColor
= FALSE
;
1250 cs
->fDontPrettyNames
= FALSE
;
1251 cs
->fAdminsCreateCommonGroups
= TRUE
;
1252 cs
->fMenuEnumFilter
= 96;
1258 /*************************************************************************
1259 * WriteCabinetState [SHELL32.652] NT 4.0
1262 BOOL WINAPI
WriteCabinetState(CABINETSTATE
*cs
)
1272 r
= RegCreateKeyExW( HKEY_CURRENT_USER
, szwCabLocation
, 0,
1273 NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
1274 if( r
== ERROR_SUCCESS
)
1276 r
= RegSetValueExW( hkey
, szwSettings
, 0,
1277 REG_BINARY
, (LPBYTE
) cs
, cs
->cLength
);
1279 RegCloseKey( hkey
);
1282 return (r
==ERROR_SUCCESS
);
1285 /*************************************************************************
1286 * FileIconInit [SHELL32.660]
1289 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
;
1319 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &hToken
))
1324 if (!GetTokenInformation(hToken
, TokenGroups
, NULL
, 0, &dwSize
))
1326 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
1328 CloseHandle(hToken
);
1333 lpGroups
= (PTOKEN_GROUPS
)HeapAlloc(GetProcessHeap(), 0, dwSize
);
1334 if (lpGroups
== NULL
)
1336 CloseHandle(hToken
);
1340 if (!GetTokenInformation(hToken
, TokenGroups
, lpGroups
, dwSize
, &dwSize
))
1342 HeapFree(GetProcessHeap(), 0, lpGroups
);
1343 CloseHandle(hToken
);
1347 CloseHandle(hToken
);
1349 if (!AllocateAndInitializeSid(&Authority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
1350 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0,
1353 HeapFree(GetProcessHeap(), 0, lpGroups
);
1357 for (i
= 0; i
< lpGroups
->GroupCount
; i
++)
1359 if (EqualSid(lpSid
, lpGroups
->Groups
[i
].Sid
))
1367 HeapFree(GetProcessHeap(), 0, lpGroups
);
1371 /*************************************************************************
1372 * SHAllocShared [SHELL32.520]
1374 * See shlwapi.SHAllocShared
1376 HANDLE WINAPI
SHAllocShared(LPCVOID lpvData
, DWORD dwSize
, DWORD dwProcId
)
1378 typedef HANDLE (WINAPI
*SHAllocSharedProc
)(LPCVOID
, DWORD
, DWORD
);
1379 static SHAllocSharedProc pSHAllocShared
;
1381 GET_FUNC(pSHAllocShared
, SHAllocSharedProc
, shlwapi
, (char*)7, NULL
);
1382 return pSHAllocShared(lpvData
, dwSize
, dwProcId
);
1385 /*************************************************************************
1386 * SHLockShared [SHELL32.521]
1388 * See shlwapi.SHLockShared
1390 LPVOID WINAPI
SHLockShared(HANDLE hShared
, DWORD dwProcId
)
1392 typedef HANDLE (WINAPI
*SHLockSharedProc
)(HANDLE
, DWORD
);
1393 static SHLockSharedProc pSHLockShared
;
1395 GET_FUNC(pSHLockShared
, SHLockSharedProc
, shlwapi
, (char*)8, NULL
);
1396 return pSHLockShared(hShared
, dwProcId
);
1399 /*************************************************************************
1400 * SHUnlockShared [SHELL32.522]
1402 * See shlwapi.SHUnlockShared
1404 BOOL WINAPI
SHUnlockShared(LPVOID lpView
)
1406 typedef HANDLE (WINAPI
*SHUnlockSharedProc
)(LPCVOID
);
1407 static SHUnlockSharedProc pSHUnlockShared
;
1409 GET_FUNC(pSHUnlockShared
, SHUnlockSharedProc
, shlwapi
, (char*)9, FALSE
);
1410 return pSHUnlockShared(lpView
) != NULL
;
1413 /*************************************************************************
1414 * SHFreeShared [SHELL32.523]
1416 * See shlwapi.SHFreeShared
1418 BOOL WINAPI
SHFreeShared(HANDLE hShared
, DWORD dwProcId
)
1420 typedef HANDLE (WINAPI
*SHFreeSharedProc
)(HANDLE
, DWORD
);
1421 static SHFreeSharedProc pSHFreeShared
;
1423 GET_FUNC(pSHFreeShared
, SHFreeSharedProc
, shlwapi
, (char*)10, FALSE
);
1424 return pSHFreeShared(hShared
, dwProcId
) != NULL
;
1427 /*************************************************************************
1428 * SetAppStartingCursor [SHELL32.99]
1430 EXTERN_C HRESULT WINAPI
SetAppStartingCursor(HWND u
, DWORD v
)
1431 { FIXME("hwnd=%p 0x%04x stub\n",u
,v
);
1435 /*************************************************************************
1436 * SHLoadOLE [SHELL32.151]
1438 * To reduce the memory usage of Windows 95, its shell32 contained an
1439 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1440 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1441 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1442 * would just call the Co* functions.
1444 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1445 * information from the shell32 "mini-COM" to ole32.dll.
1447 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1448 * detailed description.
1450 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1451 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1452 * hack in SHCoCreateInstance)
1454 HRESULT WINAPI
SHLoadOLE(LPARAM lParam
)
1455 { FIXME("0x%08lx stub\n",lParam
);
1458 /*************************************************************************
1459 * DriveType [SHELL32.64]
1462 EXTERN_C
int WINAPI
DriveType(int DriveType
)
1464 WCHAR root
[] = L
"A:\\";
1465 root
[0] = L
'A' + DriveType
;
1466 return GetDriveTypeW(root
);
1469 /*************************************************************************
1470 * InvalidateDriveType [SHELL32.65]
1471 * Unimplemented in XP SP3
1473 EXTERN_C
int WINAPI
InvalidateDriveType(int u
)
1475 TRACE("0x%08x stub\n",u
);
1479 /*************************************************************************
1480 * SHAbortInvokeCommand [SHELL32.198]
1483 EXTERN_C HRESULT WINAPI
SHAbortInvokeCommand(void)
1488 /*************************************************************************
1489 * SHOutOfMemoryMessageBox [SHELL32.126]
1492 int WINAPI
SHOutOfMemoryMessageBox(
1497 FIXME("%p %s 0x%08x stub\n",hwndOwner
, lpCaption
, uType
);
1501 /*************************************************************************
1502 * SHFlushClipboard [SHELL32.121]
1505 EXTERN_C HRESULT WINAPI
SHFlushClipboard(void)
1507 return OleFlushClipboard();
1510 /*************************************************************************
1511 * SHWaitForFileToOpen [SHELL32.97]
1514 BOOL WINAPI
SHWaitForFileToOpen(
1519 FIXME("%p 0x%08x 0x%08x stub\n", pidl
, dwFlags
, dwTimeout
);
1523 /************************************************************************
1524 * RLBuildListOfPaths [SHELL32.146]
1529 EXTERN_C DWORD WINAPI
RLBuildListOfPaths (void)
1534 /************************************************************************
1535 * SHValidateUNC [SHELL32.173]
1538 EXTERN_C BOOL WINAPI
SHValidateUNC (HWND hwndOwner
, LPWSTR pszFile
, UINT fConnect
)
1540 FIXME("0x%08x 0x%08x 0x%08x stub\n",hwndOwner
,pszFile
,fConnect
);
1544 /************************************************************************
1545 * DoEnvironmentSubstA [SHELL32.@]
1547 * See DoEnvironmentSubstW.
1549 EXTERN_C DWORD WINAPI
DoEnvironmentSubstA(LPSTR pszString
, UINT cchString
)
1553 DWORD len
= cchString
;
1555 TRACE("(%s, %d)\n", debugstr_a(pszString
), cchString
);
1556 if (pszString
== NULL
) /* Really return 0? */
1558 if ((dst
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(CHAR
))))
1560 len
= ExpandEnvironmentStringsA(pszString
, dst
, cchString
);
1561 /* len includes the terminating 0 */
1562 if (len
&& len
< cchString
)
1565 memcpy(pszString
, dst
, len
);
1570 HeapFree(GetProcessHeap(), 0, dst
);
1572 return MAKELONG(len
, res
);
1575 /************************************************************************
1576 * DoEnvironmentSubstW [SHELL32.@]
1578 * Replace all %KEYWORD% in the string with the value of the named
1579 * environment variable. If the buffer is too small, the string is not modified.
1582 * pszString [I] '\0' terminated string with %keyword%.
1583 * [O] '\0' terminated string with %keyword% substituted.
1584 * cchString [I] size of str.
1587 * Success: The string in the buffer is updated
1589 * LOWORD: characters used in the buffer, including space for the terminating 0
1590 * Failure: buffer too small. The string is not modified.
1592 * LOWORD: provided size of the buffer in characters
1594 EXTERN_C DWORD WINAPI
DoEnvironmentSubstW(LPWSTR pszString
, UINT cchString
)
1598 DWORD len
= cchString
;
1600 TRACE("(%s, %d)\n", debugstr_w(pszString
), cchString
);
1602 if ((cchString
< MAXLONG
) && (dst
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(WCHAR
))))
1604 len
= ExpandEnvironmentStringsW(pszString
, dst
, cchString
);
1605 /* len includes the terminating 0 */
1606 if (len
&& len
<= cchString
)
1609 memcpy(pszString
, dst
, len
* sizeof(WCHAR
));
1614 HeapFree(GetProcessHeap(), 0, dst
);
1616 return MAKELONG(len
, res
);
1619 /************************************************************************
1620 * DoEnvironmentSubst [SHELL32.53]
1622 * See DoEnvironmentSubstA.
1624 DWORD WINAPI
DoEnvironmentSubstAW(LPVOID x
, UINT y
)
1626 if (SHELL_OsIsUnicode())
1627 return DoEnvironmentSubstW((LPWSTR
)x
, y
);
1628 return DoEnvironmentSubstA((LPSTR
)x
, y
);
1631 /*************************************************************************
1632 * GUIDFromStringA [SHELL32.703]
1634 BOOL WINAPI
GUIDFromStringA(LPCSTR str
, LPGUID guid
)
1636 TRACE("GUIDFromStringA() stub\n");
1640 /*************************************************************************
1641 * GUIDFromStringW [SHELL32.704]
1643 BOOL WINAPI
GUIDFromStringW(LPCWSTR str
, LPGUID guid
)
1645 UNICODE_STRING guid_str
;
1647 RtlInitUnicodeString(&guid_str
, str
);
1648 return !RtlGUIDFromString(&guid_str
, guid
);
1651 /*************************************************************************
1652 * PathIsTemporaryW [SHELL32.714]
1654 EXTERN_C BOOL WINAPI
PathIsTemporaryW(LPWSTR Str
)
1656 FIXME("(%s)stub\n", debugstr_w(Str
));
1660 /*************************************************************************
1661 * PathIsTemporaryA [SHELL32.713]
1663 EXTERN_C BOOL WINAPI
PathIsTemporaryA(LPSTR Str
)
1665 FIXME("(%s)stub\n", debugstr_a(Str
));
1669 typedef struct _PSXA
1673 IShellPropSheetExt
*pspsx
[0];
1676 typedef struct _PSXA_CALL
1678 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith
;
1683 } PSXA_CALL
, *PPSXA_CALL
;
1685 static BOOL CALLBACK
PsxaCall(HPROPSHEETPAGE hpage
, LPARAM lParam
)
1687 PPSXA_CALL Call
= (PPSXA_CALL
)lParam
;
1691 if ((Call
->bMultiple
|| !Call
->bCalled
) &&
1692 Call
->lpfnAddReplaceWith(hpage
, Call
->lParam
))
1694 Call
->bCalled
= TRUE
;
1703 /*************************************************************************
1704 * SHAddFromPropSheetExtArray [SHELL32.167]
1706 UINT WINAPI
SHAddFromPropSheetExtArray(HPSXA hpsxa
, LPFNADDPROPSHEETPAGE lpfnAddPage
, LPARAM lParam
)
1710 PPSXA psxa
= (PPSXA
)hpsxa
;
1712 TRACE("(%p,%p,%08lx)\n", hpsxa
, lpfnAddPage
, lParam
);
1716 ZeroMemory(&Call
, sizeof(Call
));
1717 Call
.lpfnAddReplaceWith
= lpfnAddPage
;
1718 Call
.lParam
= lParam
;
1719 Call
.bMultiple
= TRUE
;
1721 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1722 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1724 psxa
->pspsx
[i
]->lpVtbl
->AddPages(psxa
->pspsx
[i
], PsxaCall
, (LPARAM
)&Call
);
1727 return Call
.uiCount
;
1733 /*************************************************************************
1734 * SHCreatePropSheetExtArray [SHELL32.168]
1736 HPSXA WINAPI
SHCreatePropSheetExtArray(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
)
1738 return SHCreatePropSheetExtArrayEx(hKey
, pszSubKey
, max_iface
, NULL
);
1742 /*************************************************************************
1743 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1745 EXTERN_C HPSXA WINAPI
SHCreatePropSheetExtArrayEx(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
, IDataObject
*pDataObj
)
1747 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};
1748 WCHAR szHandler
[64];
1750 WCHAR szClsidHandler
[39];
1755 HKEY hkBase
, hkPropSheetHandlers
;
1759 TRACE("(%p,%s,%u)\n", hKey
, debugstr_w(pszSubKey
), max_iface
);
1764 /* Open the registry key */
1765 lRet
= RegOpenKeyW(hKey
, pszSubKey
, &hkBase
);
1766 if (lRet
!= ERROR_SUCCESS
)
1769 lRet
= RegOpenKeyExW(hkBase
, szPropSheetSubKey
, 0, KEY_ENUMERATE_SUB_KEYS
, &hkPropSheetHandlers
);
1770 RegCloseKey(hkBase
);
1771 if (lRet
== ERROR_SUCCESS
)
1773 /* Create and initialize the Property Sheet Extensions Array */
1774 psxa
= (PPSXA
)LocalAlloc(LMEM_FIXED
| LMEM_ZEROINIT
, sizeof(PSXA
) + max_iface
* sizeof(IShellPropSheetExt
*));
1777 psxa
->uiAllocated
= max_iface
;
1779 /* Enumerate all subkeys and attempt to load the shell extensions */
1783 dwHandlerLen
= sizeof(szHandler
) / sizeof(szHandler
[0]);
1784 lRet
= RegEnumKeyExW(hkPropSheetHandlers
, dwIndex
++, szHandler
, &dwHandlerLen
, NULL
, NULL
, NULL
, NULL
);
1785 if (lRet
!= ERROR_SUCCESS
)
1787 if (lRet
== ERROR_MORE_DATA
)
1790 if (lRet
== ERROR_NO_MORE_ITEMS
)
1791 lRet
= ERROR_SUCCESS
;
1794 szHandler
[(sizeof(szHandler
) / sizeof(szHandler
[0])) - 1] = 0;
1795 hr
= CLSIDFromString(szHandler
, &clsid
);
1798 dwClsidSize
= sizeof(szClsidHandler
);
1799 if (SHGetValueW(hkPropSheetHandlers
, szHandler
, NULL
, NULL
, szClsidHandler
, &dwClsidSize
) == ERROR_SUCCESS
)
1801 szClsidHandler
[(sizeof(szClsidHandler
) / sizeof(szClsidHandler
[0])) - 1] = 0;
1802 hr
= CLSIDFromString(szClsidHandler
, &clsid
);
1807 IShellExtInit
*psxi
;
1808 IShellPropSheetExt
*pspsx
;
1810 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1811 Only if both interfaces are supported it's a real shell extension.
1812 Then call IShellExtInit's Initialize method. */
1813 if (SUCCEEDED(CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt
, (LPVOID
*)&pspsx
)))
1815 if (SUCCEEDED(pspsx
->lpVtbl
->QueryInterface(pspsx
, &IID_IShellExtInit
, (PVOID
*)&psxi
)))
1817 if (SUCCEEDED(psxi
->lpVtbl
->Initialize(psxi
, NULL
, pDataObj
, hKey
)))
1819 /* Add the IShellPropSheetExt instance to the array */
1820 psxa
->pspsx
[psxa
->uiCount
++] = pspsx
;
1825 } while (psxa
->uiCount
!= psxa
->uiAllocated
);
1828 lRet
= ERROR_NOT_ENOUGH_MEMORY
;
1830 RegCloseKey(hkPropSheetHandlers
);
1833 if (lRet
!= ERROR_SUCCESS
&& psxa
)
1835 SHDestroyPropSheetExtArray((HPSXA
)psxa
);
1842 /*************************************************************************
1843 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1845 UINT WINAPI
SHReplaceFromPropSheetExtArray(HPSXA hpsxa
, UINT uPageID
, LPFNADDPROPSHEETPAGE lpfnReplaceWith
, LPARAM lParam
)
1849 PPSXA psxa
= (PPSXA
)hpsxa
;
1851 TRACE("(%p,%u,%p,%08lx)\n", hpsxa
, uPageID
, lpfnReplaceWith
, lParam
);
1855 ZeroMemory(&Call
, sizeof(Call
));
1856 Call
.lpfnAddReplaceWith
= lpfnReplaceWith
;
1857 Call
.lParam
= lParam
;
1859 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1860 Each shell extension is only allowed to call the callback once during the callback. */
1861 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1863 Call
.bCalled
= FALSE
;
1864 psxa
->pspsx
[i
]->lpVtbl
->ReplacePage(psxa
->pspsx
[i
], uPageID
, PsxaCall
, (LPARAM
)&Call
);
1867 return Call
.uiCount
;
1873 /*************************************************************************
1874 * SHDestroyPropSheetExtArray [SHELL32.169]
1876 void WINAPI
SHDestroyPropSheetExtArray(HPSXA hpsxa
)
1879 PPSXA psxa
= (PPSXA
)hpsxa
;
1881 TRACE("(%p)\n", hpsxa
);
1885 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1887 psxa
->pspsx
[i
]->lpVtbl
->Release(psxa
->pspsx
[i
]);
1890 LocalFree((HLOCAL
)psxa
);
1894 /*************************************************************************
1895 * CIDLData_CreateFromIDArray [SHELL32.83]
1897 * Create IDataObject from PIDLs??
1899 HRESULT WINAPI
CIDLData_CreateFromIDArray(
1900 LPCITEMIDLIST pidlFolder
,
1902 LPCITEMIDLIST
*lppidlFiles
,
1903 IDataObject
**ppdataObject
)
1906 HWND hwnd
= 0; /*FIXME: who should be hwnd of owner? set to desktop */
1909 TRACE("(%p, %d, %p, %p)\n", pidlFolder
, cpidlFiles
, lppidlFiles
, ppdataObject
);
1913 for (i
= 0; i
< cpidlFiles
; i
++)
1914 pdump(lppidlFiles
[i
]);
1916 hResult
= IDataObject_Constructor(hwnd
, pidlFolder
, lppidlFiles
, cpidlFiles
, ppdataObject
);
1920 /*************************************************************************
1921 * SHCreateStdEnumFmtEtc [SHELL32.74]
1926 HRESULT WINAPI
SHCreateStdEnumFmtEtc(
1928 const FORMATETC
*lpFormats
,
1929 LPENUMFORMATETC
*ppenumFormatetc
)
1931 IEnumFORMATETC
*pef
;
1933 TRACE("cf=%d fe=%p pef=%p\n", cFormats
, lpFormats
, ppenumFormatetc
);
1935 hRes
= IEnumFORMATETC_Constructor(cFormats
, lpFormats
, &pef
);
1939 IEnumFORMATETC_AddRef(pef
);
1940 hRes
= IEnumFORMATETC_QueryInterface(pef
, &IID_IEnumFORMATETC
, (LPVOID
*)ppenumFormatetc
);
1946 /*************************************************************************
1947 * SHCreateShellFolderView (SHELL32.256)
1949 HRESULT WINAPI
SHCreateShellFolderView(const SFV_CREATE
*pcsfv
, IShellView
**ppsv
)
1955 if (!pcsfv
|| pcsfv
->cbSize
!= sizeof(*pcsfv
))
1956 return E_INVALIDARG
;
1958 TRACE("sf=%p outer=%p callback=%p\n",
1959 pcsfv
->pshf
, pcsfv
->psvOuter
, pcsfv
->psfvcb
);
1961 hRes
= IShellView_Constructor(pcsfv
->pshf
, &psf
);
1965 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppsv
);
1970 /*************************************************************************
1971 * SHFindFiles (SHELL32.90)
1973 BOOL WINAPI
SHFindFiles( LPCITEMIDLIST pidlFolder
, LPCITEMIDLIST pidlSaveFile
)
1975 FIXME("%p %p\n", pidlFolder
, pidlSaveFile
);
1979 /*************************************************************************
1980 * SHUpdateImageW (SHELL32.192)
1982 * Notifies the shell that an icon in the system image list has been changed.
1985 * pszHashItem [I] Path to file that contains the icon.
1986 * iIndex [I] Zero-based index of the icon in the file.
1987 * uFlags [I] Flags determining the icon attributes. See notes.
1988 * iImageIndex [I] Index of the icon in the system image list.
1994 * uFlags can be one or more of the following flags:
1995 * GIL_NOTFILENAME - pszHashItem is not a file name.
1996 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1998 void WINAPI
SHUpdateImageW(LPCWSTR pszHashItem
, int iIndex
, UINT uFlags
, int iImageIndex
)
2000 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
2003 /*************************************************************************
2004 * SHUpdateImageA (SHELL32.191)
2006 * See SHUpdateImageW.
2008 VOID WINAPI
SHUpdateImageA(LPCSTR pszHashItem
, INT iIndex
, UINT uFlags
, INT iImageIndex
)
2010 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
2013 INT WINAPI
SHHandleUpdateImage(LPCITEMIDLIST pidlExtra
)
2015 FIXME("%p - stub\n", pidlExtra
);
2020 BOOL WINAPI
SHObjectProperties(HWND hwnd
, DWORD dwType
, LPCWSTR szObject
, LPCWSTR szPage
)
2022 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd
, dwType
, debugstr_w(szObject
), debugstr_w(szPage
));
2027 BOOL WINAPI
SHGetNewLinkInfoA(LPCSTR pszLinkTo
, LPCSTR pszDir
, LPSTR pszName
, BOOL
*pfMustCopy
,
2030 WCHAR wszLinkTo
[MAX_PATH
];
2031 WCHAR wszDir
[MAX_PATH
];
2032 WCHAR wszName
[MAX_PATH
];
2035 MultiByteToWideChar(CP_ACP
, 0, pszLinkTo
, -1, wszLinkTo
, MAX_PATH
);
2036 MultiByteToWideChar(CP_ACP
, 0, pszDir
, -1, wszDir
, MAX_PATH
);
2038 res
= SHGetNewLinkInfoW(wszLinkTo
, wszDir
, wszName
, pfMustCopy
, uFlags
);
2041 WideCharToMultiByte(CP_ACP
, 0, wszName
, -1, pszName
, MAX_PATH
, NULL
, NULL
);
2046 BOOL WINAPI
SHGetNewLinkInfoW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
, BOOL
*pfMustCopy
,
2049 const WCHAR
*basename
;
2050 WCHAR
*dst_basename
;
2052 static const WCHAR lnkformat
[] = {'%','s','.','l','n','k',0};
2053 static const WCHAR lnkformatnum
[] = {'%','s',' ','(','%','d',')','.','l','n','k',0};
2055 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo
), debugstr_w(pszDir
),
2056 pszName
, pfMustCopy
, uFlags
);
2058 *pfMustCopy
= FALSE
;
2060 if (uFlags
& SHGNLI_PIDL
)
2062 FIXME("SHGNLI_PIDL flag unsupported\n");
2067 FIXME("ignoring flags: 0x%08x\n", uFlags
);
2069 /* FIXME: should test if the file is a shortcut or DOS program */
2070 if (GetFileAttributesW(pszLinkTo
) == INVALID_FILE_ATTRIBUTES
)
2073 basename
= strrchrW(pszLinkTo
, '\\');
2075 basename
= basename
+1;
2077 basename
= pszLinkTo
;
2079 lstrcpynW(pszName
, pszDir
, MAX_PATH
);
2080 if (!PathAddBackslashW(pszName
))
2083 dst_basename
= pszName
+ strlenW(pszName
);
2085 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformat
, basename
);
2087 while (GetFileAttributesW(pszName
) != INVALID_FILE_ATTRIBUTES
)
2089 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformatnum
, basename
, i
);
2096 /*************************************************************************
2097 * SHStartNetConnectionDialog (SHELL32.@)
2099 HRESULT WINAPI
SHStartNetConnectionDialog(HWND hwnd
, LPCSTR pszRemoteName
, DWORD dwType
)
2101 FIXME("%p, %s, 0x%08x - stub\n", hwnd
, debugstr_a(pszRemoteName
), dwType
);
2105 /*************************************************************************
2106 * SHEmptyRecycleBinA (SHELL32.@)
2108 HRESULT WINAPI
SHEmptyRecycleBinA(HWND hwnd
, LPCSTR pszRootPath
, DWORD dwFlags
)
2110 LPWSTR szRootPathW
= NULL
;
2114 TRACE("%p, %s, 0x%08x\n", hwnd
, debugstr_a(pszRootPath
), dwFlags
);
2118 len
= MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, NULL
, 0);
2120 return HRESULT_FROM_WIN32(GetLastError());
2121 szRootPathW
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
2123 return E_OUTOFMEMORY
;
2124 if (MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, szRootPathW
, len
) == 0)
2126 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2127 return HRESULT_FROM_WIN32(GetLastError());
2131 hr
= SHEmptyRecycleBinW(hwnd
, szRootPathW
, dwFlags
);
2132 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2137 HRESULT WINAPI
SHEmptyRecycleBinW(HWND hwnd
, LPCWSTR pszRootPath
, DWORD dwFlags
)
2139 WCHAR szPath
[MAX_PATH
] = {0};
2140 DWORD dwSize
, dwType
;
2143 TRACE("%p, %s, 0x%08x\n", hwnd
, debugstr_w(pszRootPath
), dwFlags
);
2145 if (!(dwFlags
& SHERB_NOCONFIRMATION
))
2148 * enumerate available files
2149 * show confirmation dialog
2151 FIXME("show confirmation dialog\n");
2154 if (dwFlags
& SHERB_NOPROGRESSUI
)
2156 ret
= EmptyRecycleBinW(pszRootPath
);
2161 * show a progress dialog
2163 ret
= EmptyRecycleBinW(pszRootPath
);
2167 return HRESULT_FROM_WIN32(GetLastError());
2169 if (!(dwFlags
& SHERB_NOSOUND
))
2171 dwSize
= sizeof(szPath
);
2172 ret
= RegGetValueW(HKEY_CURRENT_USER
,
2173 L
"AppEvents\\Schemes\\Apps\\Explorer\\EmptyRecycleBin\\.Current",
2175 RRF_RT_REG_EXPAND_SZ
,
2179 if (ret
!= ERROR_SUCCESS
)
2182 if (dwType
!= REG_EXPAND_SZ
) /* type dismatch */
2185 szPath
[(sizeof(szPath
)/sizeof(WCHAR
))-1] = L
'\0';
2186 PlaySoundW(szPath
, NULL
, SND_FILENAME
);
2191 HRESULT WINAPI
SHQueryRecycleBinA(LPCSTR pszRootPath
, LPSHQUERYRBINFO pSHQueryRBInfo
)
2193 LPWSTR szRootPathW
= NULL
;
2197 TRACE("%s, %p\n", debugstr_a(pszRootPath
), pSHQueryRBInfo
);
2201 len
= MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, NULL
, 0);
2203 return HRESULT_FROM_WIN32(GetLastError());
2204 szRootPathW
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
2206 return E_OUTOFMEMORY
;
2207 if (MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, szRootPathW
, len
) == 0)
2209 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2210 return HRESULT_FROM_WIN32(GetLastError());
2214 hr
= SHQueryRecycleBinW(szRootPathW
, pSHQueryRBInfo
);
2215 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2220 HRESULT WINAPI
SHQueryRecycleBinW(LPCWSTR pszRootPath
, LPSHQUERYRBINFO pSHQueryRBInfo
)
2222 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath
), pSHQueryRBInfo
);
2224 if (!(pszRootPath
) || (pszRootPath
[0] == 0) ||
2225 !(pSHQueryRBInfo
) || (pSHQueryRBInfo
->cbSize
< sizeof(SHQUERYRBINFO
)))
2227 return E_INVALIDARG
;
2230 pSHQueryRBInfo
->i64Size
= 0;
2231 pSHQueryRBInfo
->i64NumItems
= 0;
2236 /*************************************************************************
2237 * SHSetLocalizedName (SHELL32.@)
2239 EXTERN_C HRESULT WINAPI
SHSetLocalizedName(LPCWSTR pszPath
, LPCWSTR pszResModule
, int idsRes
)
2241 FIXME("%p, %s, %d - stub\n", pszPath
, debugstr_w(pszResModule
), idsRes
);
2246 /*************************************************************************
2247 * LinkWindow_RegisterClass (SHELL32.258)
2249 EXTERN_C BOOL WINAPI
LinkWindow_RegisterClass(void)
2255 /*************************************************************************
2256 * LinkWindow_UnregisterClass (SHELL32.259)
2258 EXTERN_C BOOL WINAPI
LinkWindow_UnregisterClass(void)
2265 /*************************************************************************
2266 * SHFlushSFCache (SHELL32.526)
2268 * Notifies the shell that a user-specified special folder location has changed.
2271 * In Wine, the shell folder registry values are not cached, so this function
2274 EXTERN_C
void WINAPI
SHFlushSFCache(void)
2278 /*************************************************************************
2279 * SHGetImageList (SHELL32.727)
2281 * Returns a copy of a shell image list.
2284 * Windows XP features 4 sizes of image list, and Vista 5. Wine currently
2285 * only supports the traditional small and large image lists, so requests
2286 * for the others will currently fail.
2288 EXTERN_C HRESULT WINAPI
SHGetImageList(int iImageList
, REFIID riid
, void **ppv
)
2290 HIMAGELIST hLarge
, hSmall
;
2292 HRESULT ret
= E_FAIL
;
2294 /* Wine currently only maintains large and small image lists */
2295 if ((iImageList
!= SHIL_LARGE
) && (iImageList
!= SHIL_SMALL
) && (iImageList
!= SHIL_SYSSMALL
))
2297 FIXME("Unsupported image list %i requested\n", iImageList
);
2301 Shell_GetImageLists(&hLarge
, &hSmall
);
2303 hNew
= ImageList_Duplicate(iImageList
== SHIL_LARGE
? hLarge
: hSmall
);
2305 /* Get the interface for the new image list */
2308 ret
= HIMAGELIST_QueryInterface(hNew
, riid
, ppv
);
2309 ImageList_Destroy(hNew
);
2312 /* Duplicating the imagelist causes the start menu items not to draw on
2313 * the first show. Was the Duplicate necessary for some reason? I believe
2314 * Windows returns the raw pointer here. */
2315 hNew
= (iImageList
== SHIL_LARGE
? hLarge
: hSmall
);
2316 ret
= IImageList2_QueryInterface((IImageList2
*) hNew
, riid
, ppv
);
2322 /*************************************************************************
2323 * SHParseDisplayName [shell version 6.0]
2325 EXTERN_C HRESULT WINAPI
SHParseDisplayName(LPCWSTR pszName
, IBindCtx
*pbc
,
2326 LPITEMIDLIST
*ppidl
, SFGAOF sfgaoIn
, SFGAOF
*psfgaoOut
)
2328 IShellFolder
*psfDesktop
;
2330 ULONG dwAttr
=sfgaoIn
;
2333 return E_INVALIDARG
;
2335 if (!pszName
|| !psfgaoOut
)
2338 return E_INVALIDARG
;
2341 hr
= SHGetDesktopFolder(&psfDesktop
);
2348 hr
= IShellFolder_ParseDisplayName(psfDesktop
, (HWND
)NULL
, pbc
, (LPOLESTR
)pszName
, (ULONG
*)NULL
, ppidl
, &dwAttr
);
2350 IShellFolder_Release(psfDesktop
);
2353 *psfgaoOut
= dwAttr
;