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
26 #include <commoncontrols.h>
28 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
29 WINE_DECLARE_DEBUG_CHANNEL(pidl
);
31 /* FIXME: !!! move flags to header file !!! */
33 #define MRUF_STRING_LIST 0 /* list will contain strings */
34 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
35 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
37 EXTERN_C HANDLE WINAPI
CreateMRUListA(LPCREATEMRULISTA lpcml
);
38 EXTERN_C INT WINAPI
AddMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
39 EXTERN_C INT WINAPI
FindMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
40 EXTERN_C INT WINAPI
EnumMRUListA(HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
43 /* Get a function pointer from a DLL handle */
44 #define GET_FUNC(func, funcType, module, name, fail) \
47 if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
48 func = (funcType)GetProcAddress(SHELL32_h##module, name); \
49 if (!func) return fail; \
53 /* Function pointers for GET_FUNC macro */
54 static HMODULE SHELL32_hshlwapi
=NULL
;
57 /*************************************************************************
58 * ParseFieldA [internal]
60 * copies a field from a ',' delimited string
62 * first field is nField = 1
64 DWORD WINAPI
ParseFieldA(
70 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src
),nField
,dst
,len
);
72 if (!src
|| !src
[0] || !dst
|| !len
)
75 /* skip n fields delimited by ',' */
78 if (*src
=='\0') return FALSE
;
79 if (*(src
++)==',') nField
--;
82 /* copy part till the next ',' to dst */
83 while ( *src
!='\0' && *src
!=',' && (len
--)>0 ) *(dst
++)=*(src
++);
85 /* finalize the string */
91 /*************************************************************************
92 * ParseFieldW [internal]
94 * copies a field from a ',' delimited string
96 * first field is nField = 1
98 DWORD WINAPI
ParseFieldW(LPCWSTR src
, DWORD nField
, LPWSTR dst
, DWORD len
)
100 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src
), nField
, dst
, len
);
102 if (!src
|| !src
[0] || !dst
|| !len
)
105 /* skip n fields delimited by ',' */
108 if (*src
== 0x0) return FALSE
;
109 if (*src
++ == ',') nField
--;
112 /* copy part till the next ',' to dst */
113 while ( *src
!= 0x0 && *src
!= ',' && (len
--)>0 ) *(dst
++) = *(src
++);
115 /* finalize the string */
121 /*************************************************************************
122 * ParseField [SHELL32.58]
124 EXTERN_C DWORD WINAPI
ParseFieldAW(LPCVOID src
, DWORD nField
, LPVOID dst
, DWORD len
)
126 if (SHELL_OsIsUnicode())
127 return ParseFieldW((LPCWSTR
)src
, nField
, (LPWSTR
)dst
, len
);
128 return ParseFieldA((LPCSTR
)src
, nField
, (LPSTR
)dst
, len
);
131 /*************************************************************************
132 * GetFileNameFromBrowse [SHELL32.63]
135 BOOL WINAPI
GetFileNameFromBrowse(
139 LPCWSTR lpstrInitialDir
,
144 typedef BOOL (WINAPI
*GetOpenFileNameProc
)(OPENFILENAMEW
*ofn
);
146 GetOpenFileNameProc pGetOpenFileNameW
;
150 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
151 hwndOwner
, debugstr_w(lpstrFile
), nMaxFile
, lpstrInitialDir
, lpstrDefExt
,
152 lpstrFilter
, lpstrTitle
);
154 hmodule
= LoadLibraryW(L
"comdlg32.dll");
155 if(!hmodule
) return FALSE
;
156 pGetOpenFileNameW
= (GetOpenFileNameProc
)GetProcAddress(hmodule
, "GetOpenFileNameW");
157 if(!pGetOpenFileNameW
)
159 FreeLibrary(hmodule
);
163 memset(&ofn
, 0, sizeof(ofn
));
165 ofn
.lStructSize
= sizeof(ofn
);
166 ofn
.hwndOwner
= hwndOwner
;
167 ofn
.lpstrFilter
= lpstrFilter
;
168 ofn
.lpstrFile
= lpstrFile
;
169 ofn
.nMaxFile
= nMaxFile
;
170 ofn
.lpstrInitialDir
= lpstrInitialDir
;
171 ofn
.lpstrTitle
= lpstrTitle
;
172 ofn
.lpstrDefExt
= lpstrDefExt
;
173 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
174 ret
= pGetOpenFileNameW(&ofn
);
176 FreeLibrary(hmodule
);
180 /*************************************************************************
181 * SHGetSetSettings [SHELL32.68]
183 EXTERN_C VOID WINAPI
SHGetSetSettings(LPSHELLSTATE lpss
, DWORD dwMask
, BOOL bSet
)
187 FIXME("%p 0x%08x TRUE\n", lpss
, dwMask
);
191 SHGetSettings((LPSHELLFLAGSTATE
)lpss
,dwMask
);
195 /*************************************************************************
196 * SHGetSettings [SHELL32.@]
199 * the registry path are for win98 (tested)
200 * and possibly are the same in nt40
203 EXTERN_C VOID WINAPI
SHGetSettings(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
)
207 DWORD dwDataSize
= sizeof (DWORD
);
209 TRACE("(%p 0x%08x)\n",lpsfs
,dwMask
);
211 if (RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
212 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0))
215 if ( (SSF_SHOWEXTENSIONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideFileExt", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
216 lpsfs
->fShowExtensions
= ((dwData
== 0) ? 0 : 1);
218 if ( (SSF_SHOWINFOTIP
& dwMask
) && !RegQueryValueExA(hKey
, "ShowInfoTip", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
219 lpsfs
->fShowInfoTip
= ((dwData
== 0) ? 0 : 1);
221 if ( (SSF_DONTPRETTYPATH
& dwMask
) && !RegQueryValueExA(hKey
, "DontPrettyPath", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
222 lpsfs
->fDontPrettyPath
= ((dwData
== 0) ? 0 : 1);
224 if ( (SSF_HIDEICONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideIcons", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
225 lpsfs
->fHideIcons
= ((dwData
== 0) ? 0 : 1);
227 if ( (SSF_MAPNETDRVBUTTON
& dwMask
) && !RegQueryValueExA(hKey
, "MapNetDrvBtn", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
228 lpsfs
->fMapNetDrvBtn
= ((dwData
== 0) ? 0 : 1);
230 if ( (SSF_SHOWATTRIBCOL
& dwMask
) && !RegQueryValueExA(hKey
, "ShowAttribCol", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
231 lpsfs
->fShowAttribCol
= ((dwData
== 0) ? 0 : 1);
233 if (((SSF_SHOWALLOBJECTS
| SSF_SHOWSYSFILES
) & dwMask
) && !RegQueryValueExA(hKey
, "Hidden", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
235 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
236 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
238 else if (dwData
== 1)
239 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 1;
240 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
242 else if (dwData
== 2)
243 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
244 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 1;
249 TRACE("-- 0x%04x\n", *(WORD
*)lpsfs
);
252 /*************************************************************************
253 * SHShellFolderView_Message [SHELL32.73]
255 * Send a message to an explorer cabinet window.
258 * hwndCabinet [I] The window containing the shellview to communicate with
259 * dwMessage [I] The SFVM message to send
260 * dwParam [I] Message parameter
266 * Message SFVM_REARRANGE = 1
268 * This message gets sent when a column gets clicked to instruct the
269 * shell view to re-sort the item list. dwParam identifies the column
272 LRESULT WINAPI
SHShellFolderView_Message(
277 FIXME("%p %08x %08lx stub\n",hwndCabinet
, uMessage
, lParam
);
281 /*************************************************************************
282 * RegisterShellHook [SHELL32.181]
284 * Register a shell hook.
287 * hwnd [I] Window handle
288 * dwType [I] Type of hook.
291 * Exported by ordinal
293 BOOL WINAPI
RegisterShellHook(
298 return RegisterShellHookWindow(hWnd
);
299 else if (dwType
== 0)
300 return DeregisterShellHookWindow(hWnd
);
302 ERR("Unsupported argument");
306 /*************************************************************************
307 * ShellMessageBoxW [SHELL32.182]
309 * See ShellMessageBoxA.
312 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
313 * because we can't forward to it in the .spec file since it's exported by
314 * ordinal. If you change the implementation here please update the code in
317 EXTERN_C
int ShellMessageBoxW(
325 WCHAR szText
[100],szTitle
[100];
326 LPCWSTR pszText
= szText
, pszTitle
= szTitle
;
331 va_start(args
, uType
);
332 /* wvsprintfA(buf,fmt, args); */
334 TRACE("(%p,%p,%p,%p,%08x)\n",
335 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
337 if (IS_INTRESOURCE(lpCaption
))
338 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]));
340 pszTitle
= lpCaption
;
342 if (IS_INTRESOURCE(lpText
))
343 LoadStringW(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
)/sizeof(szText
[0]));
347 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
348 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
352 ret
= MessageBoxW(hWnd
,pszTemp
,pszTitle
,uType
);
357 /*************************************************************************
358 * ShellMessageBoxA [SHELL32.183]
360 * Format and output an error message.
363 * hInstance [I] Instance handle of message creator
364 * hWnd [I] Window handle of message creator
365 * lpText [I] Resource Id of title or LPSTR
366 * lpCaption [I] Resource Id of title or LPSTR
367 * uType [I] Type of error message
370 * A return value from MessageBoxA().
373 * Exported by ordinal
375 EXTERN_C
int ShellMessageBoxA(
383 char szText
[100],szTitle
[100];
384 LPCSTR pszText
= szText
, pszTitle
= szTitle
;
389 va_start(args
, uType
);
390 /* wvsprintfA(buf,fmt, args); */
392 TRACE("(%p,%p,%p,%p,%08x)\n",
393 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
395 if (IS_INTRESOURCE(lpCaption
))
396 LoadStringA(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
));
398 pszTitle
= lpCaption
;
400 if (IS_INTRESOURCE(lpText
))
401 LoadStringA(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
));
405 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
406 pszText
, 0, 0, (LPSTR
)&pszTemp
, 0, &args
);
410 ret
= MessageBoxA(hWnd
,pszTemp
,pszTitle
,uType
);
415 /*************************************************************************
416 * SHRegisterDragDrop [SHELL32.86]
418 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
419 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
420 * for details. Under Windows 98 this function initializes the true OLE when called
421 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
423 * We follow Windows 98 behaviour.
426 * exported by ordinal
429 * RegisterDragDrop, SHLoadOLE
431 HRESULT WINAPI
SHRegisterDragDrop(
433 LPDROPTARGET pDropTarget
)
435 static BOOL ole_initialized
= FALSE
;
438 TRACE("(%p,%p)\n", hWnd
, pDropTarget
);
440 if (!ole_initialized
)
442 hr
= OleInitialize(NULL
);
445 ole_initialized
= TRUE
;
447 return RegisterDragDrop(hWnd
, pDropTarget
);
450 /*************************************************************************
451 * SHRevokeDragDrop [SHELL32.87]
453 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
454 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
455 * for details. Function removed from Windows Vista.
457 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
461 * exported by ordinal
464 * RevokeDragDrop, SHLoadOLE
466 HRESULT WINAPI
SHRevokeDragDrop(HWND hWnd
)
468 TRACE("(%p)\n", hWnd
);
469 return RevokeDragDrop(hWnd
);
472 /*************************************************************************
473 * SHDoDragDrop [SHELL32.88]
475 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
476 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
480 * exported by ordinal
483 * DoDragDrop, SHLoadOLE
485 HRESULT WINAPI
SHDoDragDrop(
487 IDataObject
* lpDataObject
,
488 LPDROPSOURCE lpDropSource
,
492 FIXME("(%p %p %p 0x%08x %p):stub.\n",
493 hWnd
, lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
494 return DoDragDrop(lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
497 /*************************************************************************
498 * ArrangeWindows [SHELL32.184]
501 WORD WINAPI
ArrangeWindows(
508 /* Unimplemented in WinXP SP3 */
509 TRACE("(%p 0x%08x %p 0x%04x %p):stub.\n",
510 hwndParent
, dwReserved
, lpRect
, cKids
, lpKids
);
514 /*************************************************************************
515 * SignalFileOpen [SHELL32.103]
518 * exported by ordinal
521 SignalFileOpen (LPCITEMIDLIST pidl
)
523 FIXME("(0x%08x):stub.\n", pidl
);
528 /*************************************************************************
529 * SHADD_get_policy - helper function for SHAddToRecentDocs
532 * policy [IN] policy name (null termed string) to find
533 * type [OUT] ptr to DWORD to receive type
534 * buffer [OUT] ptr to area to hold data retrieved
535 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
539 * result of the SHQueryValueEx call
541 static INT
SHADD_get_policy(LPCSTR policy
, LPDWORD type
, LPVOID buffer
, LPDWORD len
)
546 /* Get the key for the policies location in the registry
548 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
549 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
550 0, KEY_READ
, &Policy_basekey
)) {
552 if (RegOpenKeyExA(HKEY_CURRENT_USER
,
553 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
554 0, KEY_READ
, &Policy_basekey
)) {
555 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
558 return ERROR_FILE_NOT_FOUND
;
562 /* Retrieve the data if it exists
564 ret
= SHQueryValueExA(Policy_basekey
, policy
, 0, type
, buffer
, len
);
565 RegCloseKey(Policy_basekey
);
570 /*************************************************************************
571 * SHADD_compare_mru - helper function for SHAddToRecentDocs
574 * data1 [IN] data being looked for
575 * data2 [IN] data in MRU
576 * cbdata [IN] length from FindMRUData call (not used)
579 * position within MRU list that data was added.
581 static INT CALLBACK
SHADD_compare_mru(LPCVOID data1
, LPCVOID data2
, DWORD cbData
)
583 return lstrcmpiA((LPCSTR
)data1
, (LPCSTR
)data2
);
586 /*************************************************************************
587 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
590 * mruhandle [IN] handle for created MRU list
591 * doc_name [IN] null termed pure doc name
592 * new_lnk_name [IN] null termed path and file name for .lnk file
593 * buffer [IN/OUT] 2048 byte area to construct MRU data
594 * len [OUT] ptr to int to receive space used in buffer
597 * position within MRU list that data was added.
599 static INT
SHADD_create_add_mru_data(HANDLE mruhandle
, LPCSTR doc_name
, LPCSTR new_lnk_name
,
600 LPSTR buffer
, INT
*len
)
606 * RecentDocs MRU data structure seems to be:
607 * +0h document file name w/ terminating 0h
608 * +nh short int w/ size of remaining
609 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
610 * +n+4h 10 bytes zeros - unknown
611 * +n+eh shortcut file name w/ terminating 0h
612 * +n+e+nh 3 zero bytes - unknown
615 /* Create the MRU data structure for "RecentDocs"
618 lstrcpyA(ptr
, doc_name
);
619 ptr
+= (lstrlenA(buffer
) + 1);
620 wlen
= lstrlenA(new_lnk_name
) + 1 + 12;
621 *((short int*)ptr
) = wlen
;
622 ptr
+= 2; /* step past the length */
623 *(ptr
++) = 0x30; /* unknown reason */
624 *(ptr
++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
627 lstrcpyA(ptr
, new_lnk_name
);
628 ptr
+= (lstrlenA(new_lnk_name
) + 1);
633 /* Add the new entry into the MRU list
635 return AddMRUData(mruhandle
, buffer
, *len
);
638 /*************************************************************************
639 * SHAddToRecentDocs [SHELL32.@]
641 * Modify (add/clear) Shell's list of recently used documents.
644 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
645 * pv [IN] string or pidl, NULL clears the list
653 void WINAPI
SHAddToRecentDocs (UINT uFlags
,LPCVOID pv
)
655 /* If list is a string list lpfnCompare has the following prototype
656 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
657 * for binary lists the prototype is
658 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
659 * where cbData is the no. of bytes to compare.
660 * Need to check what return value means identical - 0?
666 CHAR doc_name
[MAX_PATH
];
667 CHAR link_dir
[MAX_PATH
];
668 CHAR new_lnk_filepath
[MAX_PATH
];
669 CHAR new_lnk_name
[MAX_PATH
];
671 CComPtr
<IMalloc
> ppM
;
673 HWND hwnd
= 0; /* FIXME: get real window handle */
675 DWORD data
[64], datalen
, type
;
677 TRACE("%04x %p\n", uFlags
, pv
);
680 * RecentDocs MRU data structure seems to be:
681 * +0h document file name w/ terminating 0h
682 * +nh short int w/ size of remaining
683 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
684 * +n+4h 10 bytes zeros - unknown
685 * +n+eh shortcut file name w/ terminating 0h
686 * +n+e+nh 3 zero bytes - unknown
689 /* See if we need to do anything.
692 ret
=SHADD_get_policy( "NoRecentDocsHistory", &type
, data
, &datalen
);
693 if ((ret
> 0) && (ret
!= ERROR_FILE_NOT_FOUND
)) {
694 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret
);
697 if (ret
== ERROR_SUCCESS
) {
698 if (!( (type
== REG_DWORD
) ||
699 ((type
== REG_BINARY
) && (datalen
== 4)) )) {
700 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
705 TRACE("policy value for NoRecentDocsHistory = %08x\n", data
[0]);
706 /* now test the actual policy value */
711 /* Open key to where the necessary info is
713 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
714 * and the close should be done during the _DETACH. The resulting
715 * key is stored in the DLL global data.
717 if (RegCreateKeyExA(HKEY_CURRENT_USER
,
718 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
719 0, 0, 0, KEY_READ
, 0, &HCUbasekey
, 0)) {
720 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
724 /* Get path to user's "Recent" directory
726 if(SUCCEEDED(SHGetMalloc(&ppM
))) {
727 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd
, CSIDL_RECENT
,
729 SHGetPathFromIDListA(pidl
, link_dir
);
735 ERR("serious issues 1\n");
741 ERR("serious issues 2\n");
743 TRACE("Users Recent dir %s\n", link_dir
);
745 /* If no input, then go clear the lists */
747 /* clear user's Recent dir
750 /* FIXME: delete all files in "link_dir"
752 * while( more files ) {
753 * lstrcpyA(old_lnk_name, link_dir);
754 * PathAppendA(old_lnk_name, filenam);
755 * DeleteFileA(old_lnk_name);
758 FIXME("should delete all files in %s\\\n", link_dir
);
762 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
763 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
764 * and naturally it fails w/ rc=2. It should do it against
765 * HKEY_CURRENT_USER which is where it is stored, and where
766 * the MRU routines expect it!!!!
768 RegDeleteKeyA(HCUbasekey
, "RecentDocs");
769 RegCloseKey(HCUbasekey
);
773 /* Have data to add, the jobs to be done:
774 * 1. Add document to MRU list in registry "HKCU\Software\
775 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
776 * 2. Add shortcut to document in the user's Recent directory
778 * 3. Add shortcut to Start menu's Documents submenu.
781 /* Get the pure document name from the input
786 SHGetPathFromIDListA((LPCITEMIDLIST
)pv
, doc_name
);
790 lstrcpynA(doc_name
, (LPCSTR
)pv
, MAX_PATH
);
794 WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)pv
, -1, doc_name
, MAX_PATH
, NULL
, NULL
);
798 FIXME("Unsupported flags: %u\n", uFlags
);
802 TRACE("full document name %s\n", debugstr_a(doc_name
));
804 /* check if file is a shortcut */
805 ext
= strrchr(doc_name
, '.');
806 if (!lstrcmpiA(ext
, ".lnk"))
808 CComPtr
<IShellLinkA
> ShellLink
;
809 IShellLink_ConstructFromFile(NULL
, IID_IShellLinkA
, (LPCITEMIDLIST
)SHSimpleIDListFromPathA(doc_name
), (LPVOID
*)&ShellLink
);
810 ShellLink
->GetPath(doc_name
, MAX_PATH
, NULL
, 0);
813 ext
= strrchr(doc_name
, '.');
814 if (!lstrcmpiA(ext
, ".exe"))
816 /* executables are not added */
820 PathStripPathA(doc_name
);
821 TRACE("stripped document name %s\n", debugstr_a(doc_name
));
824 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
827 * doc_name - pure file-spec, no path
828 * link_dir - path to the user's Recent directory
829 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
831 * new_lnk_name- pure file-spec, no path for new .lnk file
833 * - path and file name of new .lnk file
835 CREATEMRULISTA mymru
;
837 INT len
, pos
, bufused
, err
;
842 CHAR old_lnk_name
[MAX_PATH
];
845 mymru
.cbSize
= sizeof(CREATEMRULISTA
);
846 mymru
.nMaxItems
= 15;
847 mymru
.dwFlags
= MRUF_BINARY_LIST
| MRUF_DELAYED_SAVE
;
848 mymru
.hKey
= HCUbasekey
;
849 mymru
.lpszSubKey
= "RecentDocs";
850 mymru
.lpfnCompare
= (PROC
)SHADD_compare_mru
;
851 mruhandle
= CreateMRUListA(&mymru
);
854 ERR("MRU processing failed, handle zero\n");
855 RegCloseKey(HCUbasekey
);
858 len
= lstrlenA(doc_name
);
859 pos
= FindMRUData(mruhandle
, doc_name
, len
, 0);
861 /* Now get the MRU entry that will be replaced
862 * and delete the .lnk file for it
864 if ((bufused
= EnumMRUListA(mruhandle
, (pos
== -1) ? 14 : pos
,
865 buffer
, 2048)) != -1) {
867 ptr
+= (lstrlenA(buffer
) + 1);
868 slen
= *((short int*)ptr
);
869 ptr
+= 2; /* skip the length area */
870 if (bufused
>= slen
+ (ptr
-buffer
)) {
871 /* buffer size looks good */
872 ptr
+= 12; /* get to string */
873 len
= bufused
- (ptr
-buffer
); /* get length of buf remaining */
874 if ((lstrlenA(ptr
) > 0) && (lstrlenA(ptr
) <= len
-1)) {
875 /* appears to be good string */
876 lstrcpyA(old_lnk_name
, link_dir
);
877 PathAppendA(old_lnk_name
, ptr
);
878 if (!DeleteFileA(old_lnk_name
)) {
879 if ((attr
= GetFileAttributesA(old_lnk_name
)) == INVALID_FILE_ATTRIBUTES
) {
880 if ((err
= GetLastError()) != ERROR_FILE_NOT_FOUND
) {
881 ERR("Delete for %s failed, err=%d, attr=%08x\n",
882 old_lnk_name
, err
, attr
);
885 TRACE("old .lnk file %s did not exist\n",
890 ERR("Delete for %s failed, attr=%08x\n",
895 TRACE("deleted old .lnk file %s\n", old_lnk_name
);
901 /* Create usable .lnk file name for the "Recent" directory
903 wsprintfA(new_lnk_name
, "%s.lnk", doc_name
);
904 lstrcpyA(new_lnk_filepath
, link_dir
);
905 PathAppendA(new_lnk_filepath
, new_lnk_name
);
907 olderrormode
= SetErrorMode(SEM_FAILCRITICALERRORS
);
908 while (GetFileAttributesA(new_lnk_filepath
) != INVALID_FILE_ATTRIBUTES
) {
910 wsprintfA(new_lnk_name
, "%s (%u).lnk", doc_name
, i
);
911 lstrcpyA(new_lnk_filepath
, link_dir
);
912 PathAppendA(new_lnk_filepath
, new_lnk_name
);
914 SetErrorMode(olderrormode
);
915 TRACE("new shortcut will be %s\n", new_lnk_filepath
);
917 /* Now add the new MRU entry and data
919 pos
= SHADD_create_add_mru_data(mruhandle
, doc_name
, new_lnk_name
,
921 FreeMRUList(mruhandle
);
922 TRACE("Updated MRU list, new doc is position %d\n", pos
);
925 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
928 * doc_name - pure file-spec, no path
930 * - path and file name of new .lnk file
931 * uFlags[in] - flags on call to SHAddToRecentDocs
932 * pv[in] - document path/pidl on call to SHAddToRecentDocs
934 CComPtr
<IShellLinkA
> psl
;
935 CComPtr
<IPersistFile
> pPf
;
938 WCHAR widelink
[MAX_PATH
];
942 hres
= CoCreateInstance(CLSID_ShellLink
,
944 CLSCTX_INPROC_SERVER
,
945 IID_PPV_ARG(IShellLinkA
,&psl
));
946 if(SUCCEEDED(hres
)) {
948 hres
= psl
->QueryInterface(IID_PPV_ARG(IPersistFile
,&pPf
));
951 ERR("failed QueryInterface for IPersistFile %08x\n", hres
);
955 /* Set the document path or pidl */
956 if (uFlags
== SHARD_PIDL
) {
957 hres
= psl
->SetIDList((LPCITEMIDLIST
) pv
);
959 hres
= psl
->SetPath((LPCSTR
) pv
);
963 ERR("failed Set{IDList|Path} %08x\n", hres
);
967 lstrcpyA(desc
, "Shortcut to ");
968 lstrcatA(desc
, doc_name
);
969 hres
= psl
->SetDescription(desc
);
972 ERR("failed SetDescription %08x\n", hres
);
976 MultiByteToWideChar(CP_ACP
, 0, new_lnk_filepath
, -1,
978 /* create the short cut */
979 hres
= pPf
->Save(widelink
, TRUE
);
982 ERR("failed IPersistFile::Save %08x\n", hres
);
985 hres
= pPf
->SaveCompleted(widelink
);
986 TRACE("shortcut %s has been created, result=%08x\n",
987 new_lnk_filepath
, hres
);
990 ERR("CoCreateInstance failed, hres=%08x\n", hres
);
998 RegCloseKey(HCUbasekey
);
1002 /*************************************************************************
1003 * SHCreateShellFolderViewEx [SHELL32.174]
1005 * Create a new instance of the default Shell folder view object.
1009 * Failure: error value
1012 * see IShellFolder::CreateViewObject
1014 HRESULT WINAPI
SHCreateShellFolderViewEx(
1015 LPCSFV psvcbi
, /* [in] shelltemplate struct */
1016 IShellView
**ppv
) /* [out] IShellView pointer */
1018 CComPtr
<IShellView
> psf
;
1021 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1022 psvcbi
->pshf
, psvcbi
->pidl
, psvcbi
->pfnCallback
,
1023 psvcbi
->fvm
, psvcbi
->psvOuter
);
1026 hRes
= IShellView_Constructor(psvcbi
->pshf
, &psf
);
1030 hRes
= psf
->QueryInterface(IID_PPV_ARG(IShellView
, ppv
));
1034 /*************************************************************************
1035 * SHWinHelp [SHELL32.127]
1038 EXTERN_C HRESULT WINAPI
SHWinHelp (DWORD v
, DWORD w
, DWORD x
, DWORD z
)
1039 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v
,w
,x
,z
);
1042 /*************************************************************************
1043 * SHRunControlPanel [SHELL32.161]
1046 EXTERN_C BOOL WINAPI
SHRunControlPanel (LPCWSTR lpcszCmdLine
, HWND hwndMsgParent
)
1048 FIXME("0x%08x 0x%08x stub\n",lpcszCmdLine
,hwndMsgParent
);
1052 static IUnknown
* SHELL32_IExplorerInterface
=0;
1053 /*************************************************************************
1054 * SHSetInstanceExplorer [SHELL32.176]
1057 * Sets the interface
1059 VOID WINAPI
SHSetInstanceExplorer (IUnknown
* lpUnknown
)
1060 { TRACE("%p\n", lpUnknown
);
1061 SHELL32_IExplorerInterface
= lpUnknown
;
1063 /*************************************************************************
1064 * SHGetInstanceExplorer [SHELL32.@]
1067 * gets the interface pointer of the explorer and a reference
1069 HRESULT WINAPI
SHGetInstanceExplorer (IUnknown
**lpUnknown
)
1070 { TRACE("%p\n", lpUnknown
);
1072 *lpUnknown
= SHELL32_IExplorerInterface
;
1074 if (!SHELL32_IExplorerInterface
)
1077 SHELL32_IExplorerInterface
->AddRef();
1080 /*************************************************************************
1081 * SHFreeUnusedLibraries [SHELL32.123]
1083 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1084 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1088 * exported by ordinal
1091 * CoFreeUnusedLibraries, SHLoadOLE
1093 void WINAPI
SHFreeUnusedLibraries (void)
1096 CoFreeUnusedLibraries();
1098 /*************************************************************************
1099 * DAD_AutoScroll [SHELL32.129]
1102 BOOL WINAPI
DAD_AutoScroll(HWND hwnd
, AUTO_SCROLL_DATA
*samples
, const POINT
* pt
)
1104 FIXME("hwnd = %p %p %p\n",hwnd
,samples
,pt
);
1107 /*************************************************************************
1108 * DAD_DragEnter [SHELL32.130]
1111 BOOL WINAPI
DAD_DragEnter(HWND hwnd
)
1113 FIXME("hwnd = %p\n",hwnd
);
1116 /*************************************************************************
1117 * DAD_DragEnterEx [SHELL32.131]
1120 BOOL WINAPI
DAD_DragEnterEx(HWND hwnd
, POINT p
)
1122 FIXME("hwnd = %p (%d,%d)\n",hwnd
,p
.x
,p
.y
);
1125 /*************************************************************************
1126 * DAD_DragMove [SHELL32.134]
1129 BOOL WINAPI
DAD_DragMove(POINT p
)
1131 FIXME("(%d,%d)\n",p
.x
,p
.y
);
1134 /*************************************************************************
1135 * DAD_DragLeave [SHELL32.132]
1138 BOOL WINAPI
DAD_DragLeave(VOID
)
1143 /*************************************************************************
1144 * DAD_SetDragImage [SHELL32.136]
1149 BOOL WINAPI
DAD_SetDragImage(
1150 HIMAGELIST himlTrack
,
1153 FIXME("%p %p stub\n",himlTrack
, lppt
);
1156 /*************************************************************************
1157 * DAD_ShowDragImage [SHELL32.137]
1162 BOOL WINAPI
DAD_ShowDragImage(BOOL bShow
)
1164 FIXME("0x%08x stub\n",bShow
);
1168 static const WCHAR szwCabLocation
[] = {
1169 'S','o','f','t','w','a','r','e','\\',
1170 'M','i','c','r','o','s','o','f','t','\\',
1171 'W','i','n','d','o','w','s','\\',
1172 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1173 'E','x','p','l','o','r','e','r','\\',
1174 'C','a','b','i','n','e','t','S','t','a','t','e',0
1177 static const WCHAR szwSettings
[] = { 'S','e','t','t','i','n','g','s',0 };
1179 /*************************************************************************
1180 * ReadCabinetState [SHELL32.651] NT 4.0
1183 BOOL WINAPI
ReadCabinetState(CABINETSTATE
*cs
, int length
)
1188 TRACE("%p %d\n", cs
, length
);
1190 if( (cs
== NULL
) || (length
< (int)sizeof(*cs
)) )
1193 r
= RegOpenKeyW( HKEY_CURRENT_USER
, szwCabLocation
, &hkey
);
1194 if( r
== ERROR_SUCCESS
)
1197 r
= RegQueryValueExW( hkey
, szwSettings
,
1198 NULL
, &type
, (LPBYTE
)cs
, (LPDWORD
)&length
);
1199 RegCloseKey( hkey
);
1203 /* if we can't read from the registry, create default values */
1204 if ( (r
!= ERROR_SUCCESS
) || (cs
->cLength
< sizeof(*cs
)) ||
1205 (cs
->cLength
!= length
) )
1207 ERR("Initializing shell cabinet settings\n");
1208 memset(cs
, 0, sizeof(*cs
));
1209 cs
->cLength
= sizeof(*cs
);
1211 cs
->fFullPathTitle
= FALSE
;
1212 cs
->fSaveLocalView
= TRUE
;
1213 cs
->fNotShell
= FALSE
;
1214 cs
->fSimpleDefault
= TRUE
;
1215 cs
->fDontShowDescBar
= FALSE
;
1216 cs
->fNewWindowMode
= FALSE
;
1217 cs
->fShowCompColor
= FALSE
;
1218 cs
->fDontPrettyNames
= FALSE
;
1219 cs
->fAdminsCreateCommonGroups
= TRUE
;
1220 cs
->fMenuEnumFilter
= 96;
1226 /*************************************************************************
1227 * WriteCabinetState [SHELL32.652] NT 4.0
1230 BOOL WINAPI
WriteCabinetState(CABINETSTATE
*cs
)
1240 r
= RegCreateKeyExW( HKEY_CURRENT_USER
, szwCabLocation
, 0,
1241 NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
1242 if( r
== ERROR_SUCCESS
)
1244 r
= RegSetValueExW( hkey
, szwSettings
, 0,
1245 REG_BINARY
, (LPBYTE
) cs
, cs
->cLength
);
1247 RegCloseKey( hkey
);
1250 return (r
==ERROR_SUCCESS
);
1253 /*************************************************************************
1254 * FileIconInit [SHELL32.660]
1257 BOOL WINAPI
FileIconInit(BOOL bFullInit
)
1259 FIXME("(%s)\n", bFullInit
? "true" : "false");
1263 /*************************************************************************
1264 * IsUserAnAdmin [SHELL32.680] NT 4.0
1266 * Checks whether the current user is a member of the Administrators group.
1275 BOOL WINAPI
IsUserAnAdmin(VOID
)
1277 SID_IDENTIFIER_AUTHORITY Authority
= {SECURITY_NT_AUTHORITY
};
1280 PTOKEN_GROUPS lpGroups
;
1283 BOOL bResult
= FALSE
;
1287 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &hToken
))
1292 if (!GetTokenInformation(hToken
, TokenGroups
, NULL
, 0, &dwSize
))
1294 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
1296 CloseHandle(hToken
);
1301 lpGroups
= (PTOKEN_GROUPS
)HeapAlloc(GetProcessHeap(), 0, dwSize
);
1302 if (lpGroups
== NULL
)
1304 CloseHandle(hToken
);
1308 if (!GetTokenInformation(hToken
, TokenGroups
, lpGroups
, dwSize
, &dwSize
))
1310 HeapFree(GetProcessHeap(), 0, lpGroups
);
1311 CloseHandle(hToken
);
1315 CloseHandle(hToken
);
1317 if (!AllocateAndInitializeSid(&Authority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
1318 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0,
1321 HeapFree(GetProcessHeap(), 0, lpGroups
);
1325 for (i
= 0; i
< lpGroups
->GroupCount
; i
++)
1327 if (EqualSid(lpSid
, lpGroups
->Groups
[i
].Sid
))
1335 HeapFree(GetProcessHeap(), 0, lpGroups
);
1339 /*************************************************************************
1340 * SHAllocShared [SHELL32.520]
1342 * See shlwapi.SHAllocShared
1344 HANDLE WINAPI
SHAllocShared(LPVOID lpvData
, DWORD dwSize
, DWORD dwProcId
)
1346 typedef HANDLE (WINAPI
*SHAllocSharedProc
)(LPCVOID
, DWORD
, DWORD
);
1347 static SHAllocSharedProc pSHAllocShared
;
1349 GET_FUNC(pSHAllocShared
, SHAllocSharedProc
, shlwapi
, (char*)7, NULL
);
1350 return pSHAllocShared(lpvData
, dwSize
, dwProcId
);
1353 /*************************************************************************
1354 * SHLockShared [SHELL32.521]
1356 * See shlwapi.SHLockShared
1358 LPVOID WINAPI
SHLockShared(HANDLE hShared
, DWORD dwProcId
)
1360 typedef HANDLE (WINAPI
*SHLockSharedProc
)(HANDLE
, DWORD
);
1361 static SHLockSharedProc pSHLockShared
;
1363 GET_FUNC(pSHLockShared
, SHLockSharedProc
, shlwapi
, (char*)8, NULL
);
1364 return pSHLockShared(hShared
, dwProcId
);
1367 /*************************************************************************
1368 * SHUnlockShared [SHELL32.522]
1370 * See shlwapi.SHUnlockShared
1372 BOOL WINAPI
SHUnlockShared(LPVOID lpView
)
1374 typedef HANDLE (WINAPI
*SHUnlockSharedProc
)(LPCVOID
);
1375 static SHUnlockSharedProc pSHUnlockShared
;
1377 GET_FUNC(pSHUnlockShared
, SHUnlockSharedProc
, shlwapi
, (char*)9, FALSE
);
1378 return pSHUnlockShared(lpView
) != NULL
;
1381 /*************************************************************************
1382 * SHFreeShared [SHELL32.523]
1384 * See shlwapi.SHFreeShared
1386 BOOL WINAPI
SHFreeShared(HANDLE hShared
, DWORD dwProcId
)
1388 typedef HANDLE (WINAPI
*SHFreeSharedProc
)(HANDLE
, DWORD
);
1389 static SHFreeSharedProc pSHFreeShared
;
1391 GET_FUNC(pSHFreeShared
, SHFreeSharedProc
, shlwapi
, (char*)10, FALSE
);
1392 return pSHFreeShared(hShared
, dwProcId
) != NULL
;
1395 /*************************************************************************
1396 * SetAppStartingCursor [SHELL32.99]
1398 EXTERN_C HRESULT WINAPI
SetAppStartingCursor(HWND u
, DWORD v
)
1399 { FIXME("hwnd=%p 0x%04x stub\n",u
,v
);
1403 /*************************************************************************
1404 * SHLoadOLE [SHELL32.151]
1406 * To reduce the memory usage of Windows 95, its shell32 contained an
1407 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1408 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1409 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1410 * would just call the Co* functions.
1412 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1413 * information from the shell32 "mini-COM" to ole32.dll.
1415 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1416 * detailed description.
1418 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1419 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1420 * hack in SHCoCreateInstance)
1422 HRESULT WINAPI
SHLoadOLE(LPARAM lParam
)
1423 { FIXME("0x%08lx stub\n",lParam
);
1426 /*************************************************************************
1427 * DriveType [SHELL32.64]
1430 EXTERN_C
int WINAPI
DriveType(int DriveType
)
1432 WCHAR root
[] = L
"A:\\";
1433 root
[0] = L
'A' + DriveType
;
1434 return GetDriveTypeW(root
);
1437 /*************************************************************************
1438 * InvalidateDriveType [SHELL32.65]
1439 * Unimplemented in XP SP3
1441 EXTERN_C
int WINAPI
InvalidateDriveType(int u
)
1443 TRACE("0x%08x stub\n",u
);
1447 /*************************************************************************
1448 * SHAbortInvokeCommand [SHELL32.198]
1451 EXTERN_C HRESULT WINAPI
SHAbortInvokeCommand(void)
1456 /*************************************************************************
1457 * SHOutOfMemoryMessageBox [SHELL32.126]
1460 int WINAPI
SHOutOfMemoryMessageBox(
1465 FIXME("%p %s 0x%08x stub\n",hwndOwner
, lpCaption
, uType
);
1469 /*************************************************************************
1470 * SHFlushClipboard [SHELL32.121]
1473 EXTERN_C HRESULT WINAPI
SHFlushClipboard(void)
1475 return OleFlushClipboard();
1478 /*************************************************************************
1479 * SHWaitForFileToOpen [SHELL32.97]
1482 BOOL WINAPI
SHWaitForFileToOpen(
1487 FIXME("%p 0x%08x 0x%08x stub\n", pidl
, dwFlags
, dwTimeout
);
1491 /************************************************************************
1492 * RLBuildListOfPaths [SHELL32.146]
1497 EXTERN_C DWORD WINAPI
RLBuildListOfPaths (void)
1502 /************************************************************************
1503 * SHValidateUNC [SHELL32.173]
1506 EXTERN_C BOOL WINAPI
SHValidateUNC (HWND hwndOwner
, LPWSTR pszFile
, UINT fConnect
)
1508 FIXME("0x%08x 0x%08x 0x%08x stub\n",hwndOwner
,pszFile
,fConnect
);
1512 /************************************************************************
1513 * DoEnvironmentSubstA [SHELL32.@]
1515 * See DoEnvironmentSubstW.
1517 EXTERN_C DWORD WINAPI
DoEnvironmentSubstA(LPSTR pszString
, UINT cchString
)
1521 DWORD len
= cchString
;
1523 TRACE("(%s, %d)\n", debugstr_a(pszString
), cchString
);
1524 if (pszString
== NULL
) /* Really return 0? */
1526 if ((dst
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(CHAR
))))
1528 len
= ExpandEnvironmentStringsA(pszString
, dst
, cchString
);
1529 /* len includes the terminating 0 */
1530 if (len
&& len
< cchString
)
1533 memcpy(pszString
, dst
, len
);
1538 HeapFree(GetProcessHeap(), 0, dst
);
1540 return MAKELONG(len
, res
);
1543 /************************************************************************
1544 * DoEnvironmentSubstW [SHELL32.@]
1546 * Replace all %KEYWORD% in the string with the value of the named
1547 * environment variable. If the buffer is too small, the string is not modified.
1550 * pszString [I] '\0' terminated string with %keyword%.
1551 * [O] '\0' terminated string with %keyword% substituted.
1552 * cchString [I] size of str.
1555 * Success: The string in the buffer is updated
1557 * LOWORD: characters used in the buffer, including space for the terminating 0
1558 * Failure: buffer too small. The string is not modified.
1560 * LOWORD: provided size of the buffer in characters
1562 EXTERN_C DWORD WINAPI
DoEnvironmentSubstW(LPWSTR pszString
, UINT cchString
)
1566 DWORD len
= cchString
;
1568 TRACE("(%s, %d)\n", debugstr_w(pszString
), cchString
);
1570 if ((cchString
< MAXLONG
) && (dst
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(WCHAR
))))
1572 len
= ExpandEnvironmentStringsW(pszString
, dst
, cchString
);
1573 /* len includes the terminating 0 */
1574 if (len
&& len
<= cchString
)
1577 memcpy(pszString
, dst
, len
* sizeof(WCHAR
));
1582 HeapFree(GetProcessHeap(), 0, dst
);
1584 return MAKELONG(len
, res
);
1587 /************************************************************************
1588 * DoEnvironmentSubst [SHELL32.53]
1590 * See DoEnvironmentSubstA.
1592 DWORD WINAPI
DoEnvironmentSubstAW(LPVOID x
, UINT y
)
1594 if (SHELL_OsIsUnicode())
1595 return DoEnvironmentSubstW((LPWSTR
)x
, y
);
1596 return DoEnvironmentSubstA((LPSTR
)x
, y
);
1599 /*************************************************************************
1600 * GUIDFromStringA [SHELL32.703]
1602 BOOL WINAPI
GUIDFromStringA(LPCSTR str
, LPGUID guid
)
1604 TRACE("GUIDFromStringA() stub\n");
1608 /*************************************************************************
1609 * GUIDFromStringW [SHELL32.704]
1611 BOOL WINAPI
GUIDFromStringW(LPCWSTR str
, LPGUID guid
)
1613 UNICODE_STRING guid_str
;
1615 RtlInitUnicodeString(&guid_str
, str
);
1616 return !RtlGUIDFromString(&guid_str
, guid
);
1619 /*************************************************************************
1620 * PathIsTemporaryW [SHELL32.714]
1622 EXTERN_C BOOL WINAPI
PathIsTemporaryW(LPWSTR Str
)
1624 FIXME("(%s)stub\n", debugstr_w(Str
));
1628 /*************************************************************************
1629 * PathIsTemporaryA [SHELL32.713]
1631 EXTERN_C BOOL WINAPI
PathIsTemporaryA(LPSTR Str
)
1633 FIXME("(%s)stub\n", debugstr_a(Str
));
1637 typedef struct _PSXA
1641 IShellPropSheetExt
*pspsx
[0];
1644 typedef struct _PSXA_CALL
1646 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith
;
1651 } PSXA_CALL
, *PPSXA_CALL
;
1653 static BOOL CALLBACK
PsxaCall(HPROPSHEETPAGE hpage
, LPARAM lParam
)
1655 PPSXA_CALL Call
= (PPSXA_CALL
)lParam
;
1659 if ((Call
->bMultiple
|| !Call
->bCalled
) &&
1660 Call
->lpfnAddReplaceWith(hpage
, Call
->lParam
))
1662 Call
->bCalled
= TRUE
;
1671 /*************************************************************************
1672 * SHAddFromPropSheetExtArray [SHELL32.167]
1674 UINT WINAPI
SHAddFromPropSheetExtArray(HPSXA hpsxa
, LPFNADDPROPSHEETPAGE lpfnAddPage
, LPARAM lParam
)
1678 PPSXA psxa
= (PPSXA
)hpsxa
;
1680 TRACE("(%p,%p,%08lx)\n", hpsxa
, lpfnAddPage
, lParam
);
1684 ZeroMemory(&Call
, sizeof(Call
));
1685 Call
.lpfnAddReplaceWith
= lpfnAddPage
;
1686 Call
.lParam
= lParam
;
1687 Call
.bMultiple
= TRUE
;
1689 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1690 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1692 psxa
->pspsx
[i
]->AddPages(PsxaCall
, (LPARAM
)&Call
);
1695 return Call
.uiCount
;
1701 /*************************************************************************
1702 * SHCreatePropSheetExtArray [SHELL32.168]
1704 HPSXA WINAPI
SHCreatePropSheetExtArray(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
)
1706 return SHCreatePropSheetExtArrayEx(hKey
, pszSubKey
, max_iface
, NULL
);
1710 /*************************************************************************
1711 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1713 EXTERN_C HPSXA WINAPI
SHCreatePropSheetExtArrayEx(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
, IDataObject
*pDataObj
)
1715 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};
1716 WCHAR szHandler
[64];
1718 WCHAR szClsidHandler
[39];
1723 HKEY hkBase
, hkPropSheetHandlers
;
1727 TRACE("(%p,%s,%u)\n", hKey
, debugstr_w(pszSubKey
), max_iface
);
1732 /* Open the registry key */
1733 lRet
= RegOpenKeyW(hKey
, pszSubKey
, &hkBase
);
1734 if (lRet
!= ERROR_SUCCESS
)
1737 lRet
= RegOpenKeyExW(hkBase
, szPropSheetSubKey
, 0, KEY_ENUMERATE_SUB_KEYS
, &hkPropSheetHandlers
);
1738 RegCloseKey(hkBase
);
1739 if (lRet
== ERROR_SUCCESS
)
1741 /* Create and initialize the Property Sheet Extensions Array */
1742 psxa
= (PPSXA
)LocalAlloc(LMEM_FIXED
| LMEM_ZEROINIT
, sizeof(PSXA
) + max_iface
* sizeof(IShellPropSheetExt
*));
1745 psxa
->uiAllocated
= max_iface
;
1747 /* Enumerate all subkeys and attempt to load the shell extensions */
1751 dwHandlerLen
= sizeof(szHandler
) / sizeof(szHandler
[0]);
1752 lRet
= RegEnumKeyExW(hkPropSheetHandlers
, dwIndex
++, szHandler
, &dwHandlerLen
, NULL
, NULL
, NULL
, NULL
);
1753 if (lRet
!= ERROR_SUCCESS
)
1755 if (lRet
== ERROR_MORE_DATA
)
1758 if (lRet
== ERROR_NO_MORE_ITEMS
)
1759 lRet
= ERROR_SUCCESS
;
1762 szHandler
[(sizeof(szHandler
) / sizeof(szHandler
[0])) - 1] = 0;
1763 hr
= CLSIDFromString(szHandler
, &clsid
);
1766 dwClsidSize
= sizeof(szClsidHandler
);
1767 if (SHGetValueW(hkPropSheetHandlers
, szHandler
, NULL
, NULL
, szClsidHandler
, &dwClsidSize
) == ERROR_SUCCESS
)
1769 szClsidHandler
[(sizeof(szClsidHandler
) / sizeof(szClsidHandler
[0])) - 1] = 0;
1770 hr
= CLSIDFromString(szClsidHandler
, &clsid
);
1775 CComPtr
<IShellExtInit
> psxi
;
1776 CComPtr
<IShellPropSheetExt
> pspsx
;
1778 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1779 Only if both interfaces are supported it's a real shell extension.
1780 Then call IShellExtInit's Initialize method. */
1781 if (SUCCEEDED(CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
/* | CLSCTX_NO_CODE_DOWNLOAD */, IID_PPV_ARG(IShellPropSheetExt
, &pspsx
))))
1783 if (SUCCEEDED(pspsx
->QueryInterface(IID_PPV_ARG(IShellExtInit
, &psxi
))))
1785 if (SUCCEEDED(psxi
->Initialize(NULL
, pDataObj
, hKey
)))
1787 /* Add the IShellPropSheetExt instance to the array */
1788 psxa
->pspsx
[psxa
->uiCount
++] = pspsx
.Detach();
1793 } while (psxa
->uiCount
!= psxa
->uiAllocated
);
1796 lRet
= ERROR_NOT_ENOUGH_MEMORY
;
1798 RegCloseKey(hkPropSheetHandlers
);
1801 if (lRet
!= ERROR_SUCCESS
&& psxa
)
1803 SHDestroyPropSheetExtArray((HPSXA
)psxa
);
1810 /*************************************************************************
1811 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1813 UINT WINAPI
SHReplaceFromPropSheetExtArray(HPSXA hpsxa
, UINT uPageID
, LPFNADDPROPSHEETPAGE lpfnReplaceWith
, LPARAM lParam
)
1817 PPSXA psxa
= (PPSXA
)hpsxa
;
1819 TRACE("(%p,%u,%p,%08lx)\n", hpsxa
, uPageID
, lpfnReplaceWith
, lParam
);
1823 ZeroMemory(&Call
, sizeof(Call
));
1824 Call
.lpfnAddReplaceWith
= lpfnReplaceWith
;
1825 Call
.lParam
= lParam
;
1827 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1828 Each shell extension is only allowed to call the callback once during the callback. */
1829 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1831 Call
.bCalled
= FALSE
;
1832 psxa
->pspsx
[i
]->ReplacePage(uPageID
, PsxaCall
, (LPARAM
)&Call
);
1835 return Call
.uiCount
;
1841 /*************************************************************************
1842 * SHDestroyPropSheetExtArray [SHELL32.169]
1844 void WINAPI
SHDestroyPropSheetExtArray(HPSXA hpsxa
)
1847 PPSXA psxa
= (PPSXA
)hpsxa
;
1849 TRACE("(%p)\n", hpsxa
);
1853 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1855 psxa
->pspsx
[i
]->Release();
1858 LocalFree((HLOCAL
)psxa
);
1862 /*************************************************************************
1863 * CIDLData_CreateFromIDArray [SHELL32.83]
1865 * Create IDataObject from PIDLs??
1867 HRESULT WINAPI
CIDLData_CreateFromIDArray(
1868 LPCITEMIDLIST pidlFolder
,
1870 LPCITEMIDLIST
*lppidlFiles
,
1871 IDataObject
**ppdataObject
)
1874 HWND hwnd
= 0; /*FIXME: who should be hwnd of owner? set to desktop */
1877 TRACE("(%p, %d, %p, %p)\n", pidlFolder
, cpidlFiles
, lppidlFiles
, ppdataObject
);
1881 for (i
= 0; i
< cpidlFiles
; i
++)
1882 pdump(lppidlFiles
[i
]);
1884 hResult
= IDataObject_Constructor(hwnd
, pidlFolder
, lppidlFiles
, cpidlFiles
, ppdataObject
);
1888 /*************************************************************************
1889 * SHCreateStdEnumFmtEtc [SHELL32.74]
1894 HRESULT WINAPI
SHCreateStdEnumFmtEtc(
1896 const FORMATETC
*lpFormats
,
1897 LPENUMFORMATETC
*ppenumFormatetc
)
1899 CComPtr
<IEnumFORMATETC
> pef
;
1901 TRACE("cf=%d fe=%p pef=%p\n", cFormats
, lpFormats
, ppenumFormatetc
);
1903 hRes
= IEnumFORMATETC_Constructor(cFormats
, lpFormats
, &pef
);
1908 hRes
= pef
->QueryInterface(IID_PPV_ARG(IEnumFORMATETC
, ppenumFormatetc
));
1914 /*************************************************************************
1915 * SHCreateShellFolderView (SHELL32.256)
1917 HRESULT WINAPI
SHCreateShellFolderView(const SFV_CREATE
*pcsfv
, IShellView
**ppsv
)
1919 CComPtr
<IShellView
> psf
;
1923 if (!pcsfv
|| pcsfv
->cbSize
!= sizeof(*pcsfv
))
1924 return E_INVALIDARG
;
1926 TRACE("sf=%p outer=%p callback=%p\n",
1927 pcsfv
->pshf
, pcsfv
->psvOuter
, pcsfv
->psfvcb
);
1929 hRes
= IShellView_Constructor(pcsfv
->pshf
, &psf
);
1933 hRes
= psf
->QueryInterface(IID_PPV_ARG(IShellView
, ppsv
));
1938 /*************************************************************************
1939 * SHFindFiles (SHELL32.90)
1941 BOOL WINAPI
SHFindFiles( LPCITEMIDLIST pidlFolder
, LPCITEMIDLIST pidlSaveFile
)
1943 FIXME("%p %p\n", pidlFolder
, pidlSaveFile
);
1947 /*************************************************************************
1948 * SHUpdateImageW (SHELL32.192)
1950 * Notifies the shell that an icon in the system image list has been changed.
1953 * pszHashItem [I] Path to file that contains the icon.
1954 * iIndex [I] Zero-based index of the icon in the file.
1955 * uFlags [I] Flags determining the icon attributes. See notes.
1956 * iImageIndex [I] Index of the icon in the system image list.
1962 * uFlags can be one or more of the following flags:
1963 * GIL_NOTFILENAME - pszHashItem is not a file name.
1964 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1966 void WINAPI
SHUpdateImageW(LPCWSTR pszHashItem
, int iIndex
, UINT uFlags
, int iImageIndex
)
1968 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1971 /*************************************************************************
1972 * SHUpdateImageA (SHELL32.191)
1974 * See SHUpdateImageW.
1976 VOID WINAPI
SHUpdateImageA(LPCSTR pszHashItem
, INT iIndex
, UINT uFlags
, INT iImageIndex
)
1978 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1981 INT WINAPI
SHHandleUpdateImage(LPCITEMIDLIST pidlExtra
)
1983 FIXME("%p - stub\n", pidlExtra
);
1988 BOOL WINAPI
SHObjectProperties(HWND hwnd
, DWORD dwType
, LPCWSTR szObject
, LPCWSTR szPage
)
1990 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd
, dwType
, debugstr_w(szObject
), debugstr_w(szPage
));
1995 BOOL WINAPI
SHGetNewLinkInfoA(LPCSTR pszLinkTo
, LPCSTR pszDir
, LPSTR pszName
, BOOL
*pfMustCopy
,
1998 WCHAR wszLinkTo
[MAX_PATH
];
1999 WCHAR wszDir
[MAX_PATH
];
2000 WCHAR wszName
[MAX_PATH
];
2003 MultiByteToWideChar(CP_ACP
, 0, pszLinkTo
, -1, wszLinkTo
, MAX_PATH
);
2004 MultiByteToWideChar(CP_ACP
, 0, pszDir
, -1, wszDir
, MAX_PATH
);
2006 res
= SHGetNewLinkInfoW(wszLinkTo
, wszDir
, wszName
, pfMustCopy
, uFlags
);
2009 WideCharToMultiByte(CP_ACP
, 0, wszName
, -1, pszName
, MAX_PATH
, NULL
, NULL
);
2014 BOOL WINAPI
SHGetNewLinkInfoW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
, BOOL
*pfMustCopy
,
2017 const WCHAR
*basename
;
2018 WCHAR
*dst_basename
;
2020 static const WCHAR lnkformat
[] = {'%','s','.','l','n','k',0};
2021 static const WCHAR lnkformatnum
[] = {'%','s',' ','(','%','d',')','.','l','n','k',0};
2023 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo
), debugstr_w(pszDir
),
2024 pszName
, pfMustCopy
, uFlags
);
2026 *pfMustCopy
= FALSE
;
2028 if (uFlags
& SHGNLI_PIDL
)
2030 FIXME("SHGNLI_PIDL flag unsupported\n");
2035 FIXME("ignoring flags: 0x%08x\n", uFlags
);
2037 /* FIXME: should test if the file is a shortcut or DOS program */
2038 if (GetFileAttributesW(pszLinkTo
) == INVALID_FILE_ATTRIBUTES
)
2041 basename
= strrchrW(pszLinkTo
, '\\');
2043 basename
= basename
+1;
2045 basename
= pszLinkTo
;
2047 lstrcpynW(pszName
, pszDir
, MAX_PATH
);
2048 if (!PathAddBackslashW(pszName
))
2051 dst_basename
= pszName
+ strlenW(pszName
);
2053 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformat
, basename
);
2055 while (GetFileAttributesW(pszName
) != INVALID_FILE_ATTRIBUTES
)
2057 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformatnum
, basename
, i
);
2064 /*************************************************************************
2065 * SHStartNetConnectionDialog (SHELL32.@)
2067 HRESULT WINAPI
SHStartNetConnectionDialog(HWND hwnd
, LPCSTR pszRemoteName
, DWORD dwType
)
2069 FIXME("%p, %s, 0x%08x - stub\n", hwnd
, debugstr_a(pszRemoteName
), dwType
);
2073 /*************************************************************************
2074 * SHEmptyRecycleBinA (SHELL32.@)
2076 HRESULT WINAPI
SHEmptyRecycleBinA(HWND hwnd
, LPCSTR pszRootPath
, DWORD dwFlags
)
2078 LPWSTR szRootPathW
= NULL
;
2082 TRACE("%p, %s, 0x%08x\n", hwnd
, debugstr_a(pszRootPath
), dwFlags
);
2086 len
= MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, NULL
, 0);
2088 return HRESULT_FROM_WIN32(GetLastError());
2089 szRootPathW
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
2091 return E_OUTOFMEMORY
;
2092 if (MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, szRootPathW
, len
) == 0)
2094 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2095 return HRESULT_FROM_WIN32(GetLastError());
2099 hr
= SHEmptyRecycleBinW(hwnd
, szRootPathW
, dwFlags
);
2100 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2105 HRESULT WINAPI
SHEmptyRecycleBinW(HWND hwnd
, LPCWSTR pszRootPath
, DWORD dwFlags
)
2107 WCHAR szPath
[MAX_PATH
] = {0};
2108 DWORD dwSize
, dwType
;
2111 TRACE("%p, %s, 0x%08x\n", hwnd
, debugstr_w(pszRootPath
), dwFlags
);
2113 if (!(dwFlags
& SHERB_NOCONFIRMATION
))
2116 * enumerate available files
2117 * show confirmation dialog
2119 FIXME("show confirmation dialog\n");
2122 if (dwFlags
& SHERB_NOPROGRESSUI
)
2124 ret
= EmptyRecycleBinW(pszRootPath
);
2129 * show a progress dialog
2131 ret
= EmptyRecycleBinW(pszRootPath
);
2135 return HRESULT_FROM_WIN32(GetLastError());
2137 if (!(dwFlags
& SHERB_NOSOUND
))
2139 dwSize
= sizeof(szPath
);
2140 ret
= RegGetValueW(HKEY_CURRENT_USER
,
2141 L
"AppEvents\\Schemes\\Apps\\Explorer\\EmptyRecycleBin\\.Current",
2143 RRF_RT_REG_EXPAND_SZ
,
2147 if (ret
!= ERROR_SUCCESS
)
2150 if (dwType
!= REG_EXPAND_SZ
) /* type dismatch */
2153 szPath
[(sizeof(szPath
)/sizeof(WCHAR
))-1] = L
'\0';
2154 PlaySoundW(szPath
, NULL
, SND_FILENAME
);
2159 HRESULT WINAPI
SHQueryRecycleBinA(LPCSTR pszRootPath
, LPSHQUERYRBINFO pSHQueryRBInfo
)
2161 LPWSTR szRootPathW
= NULL
;
2165 TRACE("%s, %p\n", debugstr_a(pszRootPath
), pSHQueryRBInfo
);
2169 len
= MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, NULL
, 0);
2171 return HRESULT_FROM_WIN32(GetLastError());
2172 szRootPathW
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
2174 return E_OUTOFMEMORY
;
2175 if (MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, szRootPathW
, len
) == 0)
2177 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2178 return HRESULT_FROM_WIN32(GetLastError());
2182 hr
= SHQueryRecycleBinW(szRootPathW
, pSHQueryRBInfo
);
2183 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2188 HRESULT WINAPI
SHQueryRecycleBinW(LPCWSTR pszRootPath
, LPSHQUERYRBINFO pSHQueryRBInfo
)
2190 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath
), pSHQueryRBInfo
);
2192 if (!(pszRootPath
) || (pszRootPath
[0] == 0) ||
2193 !(pSHQueryRBInfo
) || (pSHQueryRBInfo
->cbSize
< sizeof(SHQUERYRBINFO
)))
2195 return E_INVALIDARG
;
2198 pSHQueryRBInfo
->i64Size
= 0;
2199 pSHQueryRBInfo
->i64NumItems
= 0;
2204 /*************************************************************************
2205 * SHSetLocalizedName (SHELL32.@)
2207 EXTERN_C HRESULT WINAPI
SHSetLocalizedName(LPCWSTR pszPath
, LPCWSTR pszResModule
, int idsRes
)
2209 FIXME("%p, %s, %d - stub\n", pszPath
, debugstr_w(pszResModule
), idsRes
);
2214 /*************************************************************************
2215 * LinkWindow_RegisterClass (SHELL32.258)
2217 EXTERN_C BOOL WINAPI
LinkWindow_RegisterClass(void)
2223 /*************************************************************************
2224 * LinkWindow_UnregisterClass (SHELL32.259)
2226 EXTERN_C BOOL WINAPI
LinkWindow_UnregisterClass(void)
2233 /*************************************************************************
2234 * SHFlushSFCache (SHELL32.526)
2236 * Notifies the shell that a user-specified special folder location has changed.
2239 * In Wine, the shell folder registry values are not cached, so this function
2242 EXTERN_C
void WINAPI
SHFlushSFCache(void)
2246 /*************************************************************************
2247 * SHGetImageList (SHELL32.727)
2249 * Returns a copy of a shell image list.
2252 * Windows XP features 4 sizes of image list, and Vista 5. Wine currently
2253 * only supports the traditional small and large image lists, so requests
2254 * for the others will currently fail.
2256 EXTERN_C HRESULT WINAPI
SHGetImageList(int iImageList
, REFIID riid
, void **ppv
)
2258 HIMAGELIST hLarge
, hSmall
;
2260 HRESULT ret
= E_FAIL
;
2262 /* Wine currently only maintains large and small image lists */
2263 if ((iImageList
!= SHIL_LARGE
) && (iImageList
!= SHIL_SMALL
) && (iImageList
!= SHIL_SYSSMALL
))
2265 FIXME("Unsupported image list %i requested\n", iImageList
);
2269 Shell_GetImageLists(&hLarge
, &hSmall
);
2271 // Duplicating the imagelist causes the start menu items not to draw on the first show.
2272 // Was the Duplicate necessary for some reason? I believe Windows returns the raw pointer here.
2273 hNew
= /*ImageList_Duplicate*/(iImageList
== SHIL_LARGE
? hLarge
: hSmall
);
2275 /* Get the interface for the new image list */
2278 IImageList
*imageList
= reinterpret_cast<IImageList
*>(hNew
);
2279 ret
= imageList
->QueryInterface(riid
, ppv
);
2281 // Since we are not duplicating, destroying makes no sense.
2282 /* ImageList_Destroy(hNew); */
2288 /*************************************************************************
2289 * SHParseDisplayName [shell version 6.0]
2291 EXTERN_C HRESULT WINAPI
SHParseDisplayName(LPCWSTR pszName
, IBindCtx
*pbc
,
2292 LPITEMIDLIST
*ppidl
, SFGAOF sfgaoIn
, SFGAOF
*psfgaoOut
)
2294 CComPtr
<IShellFolder
> psfDesktop
;
2296 ULONG dwAttr
=sfgaoIn
;
2299 return E_INVALIDARG
;
2301 if (!pszName
|| !psfgaoOut
)
2304 return E_INVALIDARG
;
2307 hr
= SHGetDesktopFolder(&psfDesktop
);
2314 hr
= psfDesktop
->ParseDisplayName((HWND
)NULL
, pbc
, (LPOLESTR
)pszName
, (ULONG
*)NULL
, ppidl
, &dwAttr
);
2316 psfDesktop
->Release();
2319 *psfgaoOut
= dwAttr
;