2 * The parameters of many functions changes between different OS versions
3 * (NT uses Unicode strings, 95 uses ANSI 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
33 #include "wine/debug.h"
43 #include "shell32_main.h"
47 #include "commoncontrols.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
50 WINE_DECLARE_DEBUG_CHANNEL(pidl
);
52 /* SHWaitForFileToOpen flags */
53 #define SHWFF_ADD 0x01
54 #define SHWFF_REMOVE 0x02
55 #define SHWFF_WAIT 0x04
57 /* RegisterShellHook types */
58 #define RSH_DEREGISTER 0
59 #define RSH_REGISTER 1
60 #define RSH_REGISTER_PROGMAN 2
61 #define RSH_REGISTER_TASKMAN 3
63 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
64 /* !!! it is in both here and comctl32undoc.c !!! */
65 typedef struct tagCREATEMRULIST
67 DWORD cbSize
; /* size of struct */
68 DWORD nMaxItems
; /* max no. of items in list */
69 DWORD dwFlags
; /* see below */
70 HKEY hKey
; /* root reg. key under which list is saved */
71 LPCSTR lpszSubKey
; /* reg. subkey */
72 int (CALLBACK
*lpfnCompare
)(LPCVOID
, LPCVOID
, DWORD
); /* item compare proc */
73 } CREATEMRULISTA
, *LPCREATEMRULISTA
;
76 #define MRUF_STRING_LIST 0 /* list will contain strings */
77 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
78 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
80 extern HANDLE WINAPI
CreateMRUListA(LPCREATEMRULISTA lpcml
);
81 extern DWORD WINAPI
FreeMRUList(HANDLE hMRUList
);
82 extern INT WINAPI
AddMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
83 extern INT WINAPI
FindMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
84 extern INT WINAPI
EnumMRUListA(HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
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%08lx,%p,%ld) 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%08lx,%p,%ld) 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 DWORD WINAPI
ParseFieldAW(LPCVOID src
, DWORD nField
, LPVOID dst
, DWORD len
)
156 if (SHELL_OsIsUnicode())
157 return ParseFieldW(src
, nField
, dst
, len
);
158 return ParseFieldA(src
, nField
, dst
, len
);
161 /*************************************************************************
162 * GetFileNameFromBrowseA [internal]
164 static BOOL
GetFileNameFromBrowseA(
168 LPCSTR lpstrInitialDir
,
176 TRACE("%p, %s, %ld, %s, %s, %s, %s)\n",
177 hwndOwner
, lpstrFile
, nMaxFile
, lpstrInitialDir
, lpstrDefExt
,
178 lpstrFilter
, lpstrTitle
);
180 memset(&ofn
, 0, sizeof(ofn
));
182 ofn
.lStructSize
= sizeof(ofn
);
183 ofn
.hwndOwner
= hwndOwner
;
184 ofn
.lpstrFilter
= lpstrFilter
;
185 ofn
.lpstrFile
= lpstrFile
;
186 ofn
.nMaxFile
= nMaxFile
;
187 ofn
.lpstrInitialDir
= lpstrInitialDir
;
188 ofn
.lpstrTitle
= lpstrTitle
;
189 ofn
.lpstrDefExt
= lpstrDefExt
;
190 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
191 ret
= GetOpenFileNameA(&ofn
);
196 /*************************************************************************
197 * GetFileNameFromBrowseW [internal]
199 static BOOL
GetFileNameFromBrowseW(
203 LPCWSTR lpstrInitialDir
,
211 TRACE("%p, %s, %ld, %s, %s, %s, %s)\n",
212 hwndOwner
, debugstr_w(lpstrFile
), nMaxFile
, debugstr_w(lpstrInitialDir
), debugstr_w(lpstrDefExt
),
213 debugstr_w(lpstrFilter
), debugstr_w(lpstrTitle
));
215 memset(&ofn
, 0, sizeof(ofn
));
217 ofn
.lStructSize
= sizeof(ofn
);
218 ofn
.hwndOwner
= hwndOwner
;
219 ofn
.lpstrFilter
= lpstrFilter
;
220 ofn
.lpstrFile
= lpstrFile
;
221 ofn
.nMaxFile
= nMaxFile
;
222 ofn
.lpstrInitialDir
= lpstrInitialDir
;
223 ofn
.lpstrTitle
= lpstrTitle
;
224 ofn
.lpstrDefExt
= lpstrDefExt
;
225 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
226 ret
= GetOpenFileNameW(&ofn
);
231 /*************************************************************************
232 * GetFileNameFromBrowse [SHELL32.63]
235 BOOL WINAPI
GetFileNameFromBrowseAW(
239 LPCVOID lpstrInitialDir
,
244 if (SHELL_OsIsUnicode())
245 return GetFileNameFromBrowseW(hwndOwner
, lpstrFile
, nMaxFile
, lpstrInitialDir
, lpstrDefExt
, lpstrFilter
, lpstrTitle
);
247 return GetFileNameFromBrowseA(hwndOwner
, lpstrFile
, nMaxFile
, lpstrInitialDir
, lpstrDefExt
, lpstrFilter
, lpstrTitle
);
250 /*************************************************************************
251 * SHGetSetSettings [SHELL32.68]
253 VOID WINAPI
SHGetSetSettings(LPSHELLSTATE lpss
, DWORD dwMask
, BOOL bSet
)
257 FIXME("%p 0x%08lx TRUE\n", lpss
, dwMask
);
261 SHGetSettings((LPSHELLFLAGSTATE
)lpss
,dwMask
);
265 /*************************************************************************
266 * SHGetSettings [SHELL32.@]
269 * the registry path are for win98 (tested)
270 * and possibly are the same in nt40
273 VOID WINAPI
SHGetSettings(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
)
277 DWORD dwDataSize
= sizeof (DWORD
);
279 TRACE("(%p 0x%08lx)\n",lpsfs
,dwMask
);
281 if (RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
282 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0))
285 if ( (SSF_SHOWEXTENSIONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideFileExt", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
286 lpsfs
->fShowExtensions
= ((dwData
== 0) ? 0 : 1);
288 if ( (SSF_SHOWINFOTIP
& dwMask
) && !RegQueryValueExA(hKey
, "ShowInfoTip", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
289 lpsfs
->fShowInfoTip
= ((dwData
== 0) ? 0 : 1);
291 if ( (SSF_DONTPRETTYPATH
& dwMask
) && !RegQueryValueExA(hKey
, "DontPrettyPath", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
292 lpsfs
->fDontPrettyPath
= ((dwData
== 0) ? 0 : 1);
294 if ( (SSF_HIDEICONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideIcons", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
295 lpsfs
->fHideIcons
= ((dwData
== 0) ? 0 : 1);
297 if ( (SSF_MAPNETDRVBUTTON
& dwMask
) && !RegQueryValueExA(hKey
, "MapNetDrvBtn", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
298 lpsfs
->fMapNetDrvBtn
= ((dwData
== 0) ? 0 : 1);
300 if ( (SSF_SHOWATTRIBCOL
& dwMask
) && !RegQueryValueExA(hKey
, "ShowAttribCol", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
301 lpsfs
->fShowAttribCol
= ((dwData
== 0) ? 0 : 1);
303 if (((SSF_SHOWALLOBJECTS
| SSF_SHOWSYSFILES
) & dwMask
) && !RegQueryValueExA(hKey
, "Hidden", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
305 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
306 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
308 else if (dwData
== 1)
309 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 1;
310 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
312 else if (dwData
== 2)
313 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
314 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 1;
319 TRACE("-- 0x%04x\n", *(WORD
*)lpsfs
);
322 /*************************************************************************
323 * SHShellFolderView_Message [SHELL32.73]
325 * Send a message to an explorer cabinet window.
328 * hwndCabinet [I] The window containing the shellview to communicate with
329 * dwMessage [I] The SFVM message to send
330 * dwParam [I] Message parameter
336 * Message SFVM_REARRANGE = 1
338 * This message gets sent when a column gets clicked to instruct the
339 * shell view to re-sort the item list. dwParam identifies the column
342 LRESULT WINAPI
SHShellFolderView_Message(
347 FIXME("%p %08x %08Ix stub\n",hwndCabinet
, uMessage
, lParam
);
351 /*************************************************************************
352 * RegisterShellHook [SHELL32.181]
354 * Register a shell hook.
357 * hwnd [I] Window handle
358 * dwType [I] Type of hook.
361 * Exported by ordinal
363 BOOL WINAPI
RegisterShellHook(
367 FIXME("(%p,0x%08lx):stub.\n",hWnd
, dwType
);
371 /*************************************************************************
372 * ShellMessageBoxW [SHELL32.182]
374 * See ShellMessageBoxA.
377 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
378 * because we can't forward to it in the .spec file since it's exported by
379 * ordinal. If you change the implementation here please update the code in
382 int WINAPIV
ShellMessageBoxW(
390 WCHAR szText
[100],szTitle
[100];
391 LPCWSTR pszText
= szText
, pszTitle
= szTitle
;
396 va_start(args
, uType
);
397 /* wvsprintfA(buf,fmt, args); */
399 TRACE("(%p,%p,%p,%p,%08x)\n",
400 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
402 if (IS_INTRESOURCE(lpCaption
))
403 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, ARRAY_SIZE(szTitle
));
405 pszTitle
= lpCaption
;
407 if (IS_INTRESOURCE(lpText
))
408 LoadStringW(hInstance
, LOWORD(lpText
), szText
, ARRAY_SIZE(szText
));
412 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
413 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
417 ret
= MessageBoxW(hWnd
,pszTemp
,pszTitle
,uType
);
422 /*************************************************************************
423 * ShellMessageBoxA [SHELL32.183]
425 * Format and output an error message.
428 * hInstance [I] Instance handle of message creator
429 * hWnd [I] Window handle of message creator
430 * lpText [I] Resource Id of title or LPSTR
431 * lpCaption [I] Resource Id of title or LPSTR
432 * uType [I] Type of error message
435 * A return value from MessageBoxA().
438 * Exported by ordinal
440 int WINAPIV
ShellMessageBoxA(
448 char szText
[100],szTitle
[100];
449 LPCSTR pszText
= szText
, pszTitle
= szTitle
;
454 va_start(args
, uType
);
455 /* wvsprintfA(buf,fmt, args); */
457 TRACE("(%p,%p,%p,%p,%08x)\n",
458 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
460 if (IS_INTRESOURCE(lpCaption
))
461 LoadStringA(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
));
463 pszTitle
= lpCaption
;
465 if (IS_INTRESOURCE(lpText
))
466 LoadStringA(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
));
470 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
471 pszText
, 0, 0, (LPSTR
)&pszTemp
, 0, &args
);
475 ret
= MessageBoxA(hWnd
,pszTemp
,pszTitle
,uType
);
480 /*************************************************************************
481 * SHRegisterDragDrop [SHELL32.86]
483 * Probably equivalent to RegisterDragDrop 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. Under Windows 98 this function initializes the true OLE when called
486 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
488 * We follow Windows 98 behaviour.
491 * exported by ordinal
494 * RegisterDragDrop, SHLoadOLE
496 HRESULT WINAPI
SHRegisterDragDrop(
498 LPDROPTARGET pDropTarget
)
500 static BOOL ole_initialized
= FALSE
;
503 TRACE("(%p,%p)\n", hWnd
, pDropTarget
);
505 if (!ole_initialized
)
507 hr
= OleInitialize(NULL
);
510 ole_initialized
= TRUE
;
512 return RegisterDragDrop(hWnd
, pDropTarget
);
515 /*************************************************************************
516 * SHRevokeDragDrop [SHELL32.87]
518 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
519 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
520 * for details. Function removed from Windows Vista.
522 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
526 * exported by ordinal
529 * RevokeDragDrop, SHLoadOLE
531 HRESULT WINAPI
SHRevokeDragDrop(HWND hWnd
)
533 TRACE("(%p)\n", hWnd
);
534 return RevokeDragDrop(hWnd
);
537 /*************************************************************************
538 * SHDoDragDrop [SHELL32.88]
540 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
541 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
545 * exported by ordinal
548 * DoDragDrop, SHLoadOLE
550 HRESULT WINAPI
SHDoDragDrop(
552 LPDATAOBJECT lpDataObject
,
553 LPDROPSOURCE lpDropSource
,
557 FIXME("(%p %p %p 0x%08lx %p):stub.\n",
558 hWnd
, lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
559 return DoDragDrop(lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
562 /*************************************************************************
563 * ArrangeWindows [SHELL32.184]
566 WORD WINAPI
ArrangeWindows(HWND hwndParent
, DWORD dwReserved
, const RECT
*lpRect
,
567 WORD cKids
, const HWND
*lpKids
)
569 FIXME("(%p 0x%08lx %p 0x%04x %p):stub.\n",
570 hwndParent
, dwReserved
, lpRect
, cKids
, lpKids
);
574 /*************************************************************************
575 * SignalFileOpen [SHELL32.103]
578 * exported by ordinal
581 SignalFileOpen (PCIDLIST_ABSOLUTE pidl
)
583 FIXME("(%p):stub.\n", pidl
);
588 /*************************************************************************
589 * SHADD_get_policy - helper function for SHAddToRecentDocs
592 * policy [IN] policy name (null termed string) to find
593 * type [OUT] ptr to DWORD to receive type
594 * buffer [OUT] ptr to area to hold data retrieved
595 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
599 * result of the SHQueryValueEx call
601 static INT
SHADD_get_policy(LPCSTR policy
, LPDWORD type
, LPVOID buffer
, LPDWORD len
)
606 /* Get the key for the policies location in the registry
608 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
609 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
610 0, KEY_READ
, &Policy_basekey
)) {
612 if (RegOpenKeyExA(HKEY_CURRENT_USER
,
613 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
614 0, KEY_READ
, &Policy_basekey
)) {
615 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
618 return ERROR_FILE_NOT_FOUND
;
622 /* Retrieve the data if it exists
624 ret
= SHQueryValueExA(Policy_basekey
, policy
, 0, type
, buffer
, len
);
625 RegCloseKey(Policy_basekey
);
630 /*************************************************************************
631 * SHADD_compare_mru - helper function for SHAddToRecentDocs
634 * data1 [IN] data being looked for
635 * data2 [IN] data in MRU
636 * cbdata [IN] length from FindMRUData call (not used)
639 * position within MRU list that data was added.
641 static INT CALLBACK
SHADD_compare_mru(LPCVOID data1
, LPCVOID data2
, DWORD cbData
)
643 return lstrcmpiA(data1
, data2
);
646 /*************************************************************************
647 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
650 * mruhandle [IN] handle for created MRU list
651 * doc_name [IN] null termed pure doc name
652 * new_lnk_name [IN] null termed path and file name for .lnk file
653 * buffer [IN/OUT] 2048 byte area to construct MRU data
654 * len [OUT] ptr to int to receive space used in buffer
657 * position within MRU list that data was added.
659 static INT
SHADD_create_add_mru_data(HANDLE mruhandle
, LPCSTR doc_name
, LPCSTR new_lnk_name
,
660 LPSTR buffer
, INT
*len
)
666 * RecentDocs MRU data structure seems to be:
667 * +0h document file name w/ terminating 0h
668 * +nh short int w/ size of remaining
669 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
670 * +n+4h 10 bytes zeros - unknown
671 * +n+eh shortcut file name w/ terminating 0h
672 * +n+e+nh 3 zero bytes - unknown
675 /* Create the MRU data structure for "RecentDocs"
678 lstrcpyA(ptr
, doc_name
);
679 ptr
+= (lstrlenA(buffer
) + 1);
680 wlen
= lstrlenA(new_lnk_name
) + 1 + 12;
681 *((short int*)ptr
) = wlen
;
682 ptr
+= 2; /* step past the length */
683 *(ptr
++) = 0x30; /* unknown reason */
684 *(ptr
++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
687 lstrcpyA(ptr
, new_lnk_name
);
688 ptr
+= (lstrlenA(new_lnk_name
) + 1);
693 /* Add the new entry into the MRU list
695 return AddMRUData(mruhandle
, buffer
, *len
);
698 /*************************************************************************
699 * SHAddToRecentDocs [SHELL32.@]
701 * Modify (add/clear) Shell's list of recently used documents.
704 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
705 * pv [IN] string or pidl, NULL clears the list
713 void WINAPI
SHAddToRecentDocs (UINT uFlags
,LPCVOID pv
)
715 /* If list is a string list lpfnCompare has the following prototype
716 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
717 * for binary lists the prototype is
718 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
719 * where cbData is the no. of bytes to compare.
720 * Need to check what return value means identical - 0?
726 CHAR doc_name
[MAX_PATH
];
727 CHAR link_dir
[MAX_PATH
];
728 CHAR new_lnk_filepath
[MAX_PATH
];
729 CHAR new_lnk_name
[MAX_PATH
];
731 HWND hwnd
= 0; /* FIXME: get real window handle */
733 DWORD data
[64], datalen
, type
;
735 TRACE("%04x %p\n", uFlags
, pv
);
738 * RecentDocs MRU data structure seems to be:
739 * +0h document file name w/ terminating 0h
740 * +nh short int w/ size of remaining
741 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
742 * +n+4h 10 bytes zeros - unknown
743 * +n+eh shortcut file name w/ terminating 0h
744 * +n+e+nh 3 zero bytes - unknown
747 /* See if we need to do anything.
750 ret
=SHADD_get_policy( "NoRecentDocsHistory", &type
, data
, &datalen
);
751 if ((ret
> 0) && (ret
!= ERROR_FILE_NOT_FOUND
)) {
752 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret
);
755 if (ret
== ERROR_SUCCESS
) {
756 if (!( (type
== REG_DWORD
) ||
757 ((type
== REG_BINARY
) && (datalen
== 4)) )) {
758 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%ld, len=%ld\n",
763 TRACE("policy value for NoRecentDocsHistory = %08lx\n", data
[0]);
764 /* now test the actual policy value */
769 /* Open key to where the necessary info is
771 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
772 * and the close should be done during the _DETACH. The resulting
773 * key is stored in the DLL global data.
775 if (RegCreateKeyExA(HKEY_CURRENT_USER
,
776 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
777 0, 0, 0, KEY_READ
, 0, &HCUbasekey
, 0)) {
778 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
782 /* Get path to user's "Recent" directory
784 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd
, CSIDL_RECENT
, &pidl
)))
786 SHGetPathFromIDListA(pidl
, link_dir
);
793 ERR("serious issues 1\n");
796 TRACE("Users Recent dir %s\n", link_dir
);
798 /* If no input, then go clear the lists */
800 /* clear user's Recent dir
803 /* FIXME: delete all files in "link_dir"
805 * while( more files ) {
806 * lstrcpyA(old_lnk_name, link_dir);
807 * PathAppendA(old_lnk_name, filenam);
808 * DeleteFileA(old_lnk_name);
811 FIXME("should delete all files in %s\\\n", link_dir
);
815 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
816 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
817 * and naturally it fails w/ rc=2. It should do it against
818 * HKEY_CURRENT_USER which is where it is stored, and where
819 * the MRU routines expect it!!!!
821 RegDeleteKeyA(HCUbasekey
, "RecentDocs");
822 RegCloseKey(HCUbasekey
);
826 /* Have data to add, the jobs to be done:
827 * 1. Add document to MRU list in registry "HKCU\Software\
828 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
829 * 2. Add shortcut to document in the user's Recent directory
831 * 3. Add shortcut to Start menu's Documents submenu.
834 /* Get the pure document name from the input
839 if (!SHGetPathFromIDListA(pv
, doc_name
))
841 WARN("can't get path from PIDL\n");
847 lstrcpynA(doc_name
, pv
, MAX_PATH
);
851 WideCharToMultiByte(CP_ACP
, 0, pv
, -1, doc_name
, MAX_PATH
, NULL
, NULL
);
855 FIXME("Unsupported flags: %u\n", uFlags
);
859 TRACE("full document name %s\n", debugstr_a(doc_name
));
860 PathStripPathA(doc_name
);
861 TRACE("stripped document name %s\n", debugstr_a(doc_name
));
864 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
867 * doc_name - pure file-spec, no path
868 * link_dir - path to the user's Recent directory
869 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
871 * new_lnk_name- pure file-spec, no path for new .lnk file
873 * - path and file name of new .lnk file
875 CREATEMRULISTA mymru
;
877 INT len
, pos
, bufused
, err
;
882 CHAR old_lnk_name
[MAX_PATH
];
885 mymru
.cbSize
= sizeof(CREATEMRULISTA
);
886 mymru
.nMaxItems
= 15;
887 mymru
.dwFlags
= MRUF_BINARY_LIST
| MRUF_DELAYED_SAVE
;
888 mymru
.hKey
= HCUbasekey
;
889 mymru
.lpszSubKey
= "RecentDocs";
890 mymru
.lpfnCompare
= SHADD_compare_mru
;
891 mruhandle
= CreateMRUListA(&mymru
);
894 ERR("MRU processing failed, handle zero\n");
895 RegCloseKey(HCUbasekey
);
898 len
= lstrlenA(doc_name
);
899 pos
= FindMRUData(mruhandle
, doc_name
, len
, 0);
901 /* Now get the MRU entry that will be replaced
902 * and delete the .lnk file for it
904 if ((bufused
= EnumMRUListA(mruhandle
, (pos
== -1) ? 14 : pos
,
905 buffer
, 2048)) != -1) {
907 ptr
+= (lstrlenA(buffer
) + 1);
908 slen
= *((short int*)ptr
);
909 ptr
+= 2; /* skip the length area */
910 if (bufused
>= slen
+ (ptr
-buffer
)) {
911 /* buffer size looks good */
912 ptr
+= 12; /* get to string */
913 len
= bufused
- (ptr
-buffer
); /* get length of buf remaining */
914 if (ptr
[0] && (lstrlenA(ptr
) <= len
-1)) {
915 /* appears to be good string */
916 lstrcpyA(old_lnk_name
, link_dir
);
917 PathAppendA(old_lnk_name
, ptr
);
918 if (!DeleteFileA(old_lnk_name
)) {
919 if ((attr
= GetFileAttributesA(old_lnk_name
)) == INVALID_FILE_ATTRIBUTES
) {
920 if ((err
= GetLastError()) != ERROR_FILE_NOT_FOUND
) {
921 ERR("Delete for %s failed, err=%d, attr=%08lx\n",
922 old_lnk_name
, err
, attr
);
925 TRACE("old .lnk file %s did not exist\n",
930 ERR("Delete for %s failed, attr=%08lx\n",
935 TRACE("deleted old .lnk file %s\n", old_lnk_name
);
941 /* Create usable .lnk file name for the "Recent" directory
943 wsprintfA(new_lnk_name
, "%s.lnk", doc_name
);
944 lstrcpyA(new_lnk_filepath
, link_dir
);
945 PathAppendA(new_lnk_filepath
, new_lnk_name
);
947 olderrormode
= SetErrorMode(SEM_FAILCRITICALERRORS
);
948 while (GetFileAttributesA(new_lnk_filepath
) != INVALID_FILE_ATTRIBUTES
) {
950 wsprintfA(new_lnk_name
, "%s (%u).lnk", doc_name
, i
);
951 lstrcpyA(new_lnk_filepath
, link_dir
);
952 PathAppendA(new_lnk_filepath
, new_lnk_name
);
954 SetErrorMode(olderrormode
);
955 TRACE("new shortcut will be %s\n", new_lnk_filepath
);
957 /* Now add the new MRU entry and data
959 pos
= SHADD_create_add_mru_data(mruhandle
, doc_name
, new_lnk_name
,
961 FreeMRUList(mruhandle
);
962 TRACE("Updated MRU list, new doc is position %d\n", pos
);
965 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
968 * doc_name - pure file-spec, no path
970 * - path and file name of new .lnk file
971 * uFlags[in] - flags on call to SHAddToRecentDocs
972 * pv[in] - document path/pidl on call to SHAddToRecentDocs
974 IShellLinkA
*psl
= NULL
;
975 IPersistFile
*pPf
= NULL
;
978 WCHAR widelink
[MAX_PATH
];
982 hres
= CoCreateInstance( &CLSID_ShellLink
,
984 CLSCTX_INPROC_SERVER
,
987 if(SUCCEEDED(hres
)) {
989 hres
= IShellLinkA_QueryInterface(psl
, &IID_IPersistFile
,
993 ERR("failed QueryInterface for IPersistFile %08lx\n", hres
);
997 /* Set the document path or pidl */
998 if (uFlags
== SHARD_PIDL
) {
999 hres
= IShellLinkA_SetIDList(psl
, pv
);
1001 hres
= IShellLinkA_SetPath(psl
, pv
);
1005 ERR("failed Set{IDList|Path} %08lx\n", hres
);
1009 lstrcpyA(desc
, "Shortcut to ");
1010 lstrcatA(desc
, doc_name
);
1011 hres
= IShellLinkA_SetDescription(psl
, desc
);
1014 ERR("failed SetDescription %08lx\n", hres
);
1018 MultiByteToWideChar(CP_ACP
, 0, new_lnk_filepath
, -1,
1019 widelink
, MAX_PATH
);
1020 /* create the short cut */
1021 hres
= IPersistFile_Save(pPf
, widelink
, TRUE
);
1024 ERR("failed IPersistFile::Save %08lx\n", hres
);
1025 IPersistFile_Release(pPf
);
1026 IShellLinkA_Release(psl
);
1029 hres
= IPersistFile_SaveCompleted(pPf
, widelink
);
1030 IPersistFile_Release(pPf
);
1031 IShellLinkA_Release(psl
);
1032 TRACE("shortcut %s has been created, result=%08lx\n",
1033 new_lnk_filepath
, hres
);
1036 ERR("CoCreateInstance failed, hres=%08lx\n", hres
);
1044 RegCloseKey(HCUbasekey
);
1048 /*************************************************************************
1049 * SHWinHelp [SHELL32.127]
1052 HRESULT WINAPI
SHWinHelp (DWORD v
, DWORD w
, DWORD x
, DWORD z
)
1053 { FIXME("0x%08lx 0x%08lx 0x%08lx 0x%08lx stub\n",v
,w
,x
,z
);
1056 /*************************************************************************
1057 * SHRunControlPanel [SHELL32.161]
1060 BOOL WINAPI
SHRunControlPanel (LPCWSTR commandLine
, HWND parent
)
1062 FIXME("(%s, %p): stub\n", debugstr_w(commandLine
), parent
);
1066 /*************************************************************************
1067 * SHFreeUnusedLibraries [SHELL32.123]
1069 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1070 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1074 * exported by ordinal
1077 * CoFreeUnusedLibraries, SHLoadOLE
1079 void WINAPI
SHFreeUnusedLibraries (void)
1082 CoFreeUnusedLibraries();
1084 /*************************************************************************
1085 * DAD_AutoScroll [SHELL32.129]
1088 BOOL WINAPI
DAD_AutoScroll(HWND hwnd
, AUTO_SCROLL_DATA
*samples
, LPPOINT pt
)
1090 FIXME("hwnd = %p %p %p\n",hwnd
,samples
,pt
);
1093 /*************************************************************************
1094 * DAD_DragEnter [SHELL32.130]
1097 BOOL WINAPI
DAD_DragEnter(HWND hwnd
)
1099 FIXME("hwnd = %p\n",hwnd
);
1102 /*************************************************************************
1103 * DAD_DragEnterEx [SHELL32.131]
1106 BOOL WINAPI
DAD_DragEnterEx(HWND hwnd
, POINT p
)
1108 FIXME("hwnd = %p (%ld,%ld)\n",hwnd
,p
.x
,p
.y
);
1111 /*************************************************************************
1112 * DAD_DragMove [SHELL32.134]
1115 BOOL WINAPI
DAD_DragMove(POINT p
)
1117 FIXME("(%ld,%ld)\n",p
.x
,p
.y
);
1120 /*************************************************************************
1121 * DAD_DragLeave [SHELL32.132]
1124 BOOL WINAPI
DAD_DragLeave(VOID
)
1129 /*************************************************************************
1130 * DAD_SetDragImage [SHELL32.136]
1135 BOOL WINAPI
DAD_SetDragImage(
1136 HIMAGELIST himlTrack
,
1139 FIXME("%p %p stub\n",himlTrack
, lppt
);
1142 /*************************************************************************
1143 * DAD_ShowDragImage [SHELL32.137]
1148 BOOL WINAPI
DAD_ShowDragImage(BOOL bShow
)
1150 FIXME("0x%08x stub\n",bShow
);
1154 /*************************************************************************
1155 * ReadCabinetState [SHELL32.651] NT 4.0
1158 BOOL WINAPI
ReadCabinetState(CABINETSTATE
*cs
, int length
)
1163 TRACE("%p %d\n", cs
, length
);
1165 if( (cs
== NULL
) || (length
< (int)sizeof(*cs
)) )
1168 r
= RegOpenKeyW( HKEY_CURRENT_USER
, L
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState", &hkey
);
1169 if( r
== ERROR_SUCCESS
)
1172 r
= RegQueryValueExW( hkey
, L
"Settings", NULL
, &type
, (LPBYTE
)cs
, (LPDWORD
)&length
);
1173 RegCloseKey( hkey
);
1177 /* if we can't read from the registry, create default values */
1178 if ( (r
!= ERROR_SUCCESS
) || (cs
->cLength
< sizeof(*cs
)) ||
1179 (cs
->cLength
!= length
) )
1181 ERR("Initializing shell cabinet settings\n");
1182 memset(cs
, 0, sizeof(*cs
));
1183 cs
->cLength
= sizeof(*cs
);
1185 cs
->fFullPathTitle
= FALSE
;
1186 cs
->fSaveLocalView
= TRUE
;
1187 cs
->fNotShell
= FALSE
;
1188 cs
->fSimpleDefault
= TRUE
;
1189 cs
->fDontShowDescBar
= FALSE
;
1190 cs
->fNewWindowMode
= FALSE
;
1191 cs
->fShowCompColor
= FALSE
;
1192 cs
->fDontPrettyNames
= FALSE
;
1193 cs
->fAdminsCreateCommonGroups
= TRUE
;
1194 cs
->fMenuEnumFilter
= 96;
1200 /*************************************************************************
1201 * WriteCabinetState [SHELL32.652] NT 4.0
1204 BOOL WINAPI
WriteCabinetState(CABINETSTATE
*cs
)
1214 r
= RegCreateKeyExW( HKEY_CURRENT_USER
, L
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState", 0,
1215 NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
1216 if( r
== ERROR_SUCCESS
)
1218 r
= RegSetValueExW( hkey
, L
"Settings", 0, REG_BINARY
, (LPBYTE
) cs
, cs
->cLength
);
1219 RegCloseKey( hkey
);
1222 return (r
==ERROR_SUCCESS
);
1225 /*************************************************************************
1226 * FileIconInit [SHELL32.660]
1229 BOOL WINAPI
FileIconInit(BOOL bFullInit
)
1230 { FIXME("(%s)\n", bFullInit
? "true" : "false");
1234 /*************************************************************************
1235 * IsUserAnAdmin [SHELL32.680] NT 4.0
1237 * Checks whether the current user is a member of the Administrators group.
1246 BOOL WINAPI
IsUserAnAdmin(VOID
)
1248 SID_IDENTIFIER_AUTHORITY Authority
= {SECURITY_NT_AUTHORITY
};
1251 PTOKEN_GROUPS lpGroups
;
1254 BOOL bResult
= FALSE
;
1257 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &hToken
))
1262 if (!GetTokenInformation(hToken
, TokenGroups
, NULL
, 0, &dwSize
))
1264 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
1266 CloseHandle(hToken
);
1271 lpGroups
= heap_alloc(dwSize
);
1272 if (lpGroups
== NULL
)
1274 CloseHandle(hToken
);
1278 if (!GetTokenInformation(hToken
, TokenGroups
, lpGroups
, dwSize
, &dwSize
))
1280 heap_free(lpGroups
);
1281 CloseHandle(hToken
);
1285 CloseHandle(hToken
);
1286 if (!AllocateAndInitializeSid(&Authority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
1287 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0,
1290 heap_free(lpGroups
);
1294 for (i
= 0; i
< lpGroups
->GroupCount
; i
++)
1296 if (EqualSid(lpSid
, lpGroups
->Groups
[i
].Sid
))
1304 heap_free(lpGroups
);
1308 /*************************************************************************
1309 * SetAppStartingCursor [SHELL32.99]
1311 HRESULT WINAPI
SetAppStartingCursor(HWND u
, DWORD v
)
1312 { FIXME("hwnd=%p 0x%04lx stub\n",u
,v
);
1316 /*************************************************************************
1317 * SHLoadOLE [SHELL32.151]
1319 * To reduce the memory usage of Windows 95, its shell32 contained an
1320 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1321 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1322 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1323 * would just call the Co* functions.
1325 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1326 * information from the shell32 "mini-COM" to ole32.dll.
1328 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1329 * detailed description.
1331 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1332 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1333 * hack in SHCoCreateInstance)
1335 HRESULT WINAPI
SHLoadOLE(LPARAM lParam
)
1336 { FIXME("0x%08Ix stub\n",lParam
);
1339 /*************************************************************************
1340 * DriveType [SHELL32.64]
1343 int WINAPI
DriveType(int u
)
1344 { FIXME("0x%04x stub\n",u
);
1347 /*************************************************************************
1348 * InvalidateDriveType [SHELL32.65]
1351 int WINAPI
InvalidateDriveType(int u
)
1352 { FIXME("0x%08x stub\n",u
);
1355 /*************************************************************************
1356 * SHAbortInvokeCommand [SHELL32.198]
1359 HRESULT WINAPI
SHAbortInvokeCommand(void)
1363 /*************************************************************************
1364 * SHOutOfMemoryMessageBox [SHELL32.126]
1367 int WINAPI
SHOutOfMemoryMessageBox(
1372 FIXME("%p %s 0x%08x stub\n",hwndOwner
, lpCaption
, uType
);
1375 /*************************************************************************
1376 * SHFlushClipboard [SHELL32.121]
1379 HRESULT WINAPI
SHFlushClipboard(void)
1384 /*************************************************************************
1385 * SHWaitForFileToOpen [SHELL32.97]
1388 BOOL WINAPI
SHWaitForFileToOpen(
1393 FIXME("%p 0x%08lx 0x%08lx stub\n", pidl
, dwFlags
, dwTimeout
);
1397 /************************************************************************
1398 * RLBuildListOfPaths [SHELL32.146]
1403 DWORD WINAPI
RLBuildListOfPaths (void)
1407 /************************************************************************
1408 * SHValidateUNC [SHELL32.173]
1411 BOOL WINAPI
SHValidateUNC (HWND hwndOwner
, PWSTR pszFile
, UINT fConnect
)
1413 FIXME("(%p, %s, 0x%08x): stub\n", hwndOwner
, debugstr_w(pszFile
), fConnect
);
1417 /************************************************************************
1418 * DoEnvironmentSubstA [SHELL32.@]
1420 * See DoEnvironmentSubstW.
1422 DWORD WINAPI
DoEnvironmentSubstA(LPSTR pszString
, UINT cchString
)
1426 DWORD len
= cchString
;
1428 TRACE("(%s, %d)\n", debugstr_a(pszString
), cchString
);
1430 if ((dst
= heap_alloc(cchString
* sizeof(CHAR
))))
1432 len
= ExpandEnvironmentStringsA(pszString
, dst
, cchString
);
1433 /* len includes the terminating 0 */
1434 if (len
&& len
< cchString
)
1437 memcpy(pszString
, dst
, len
);
1444 return MAKELONG(len
, res
);
1447 /************************************************************************
1448 * DoEnvironmentSubstW [SHELL32.@]
1450 * Replace all %KEYWORD% in the string with the value of the named
1451 * environment variable. If the buffer is too small, the string is not modified.
1454 * pszString [I] '\0' terminated string with %keyword%.
1455 * [O] '\0' terminated string with %keyword% substituted.
1456 * cchString [I] size of str.
1459 * Success: The string in the buffer is updated
1461 * LOWORD: characters used in the buffer, including space for the terminating 0
1462 * Failure: buffer too small. The string is not modified.
1464 * LOWORD: provided size of the buffer in characters
1466 DWORD WINAPI
DoEnvironmentSubstW(LPWSTR pszString
, UINT cchString
)
1470 DWORD len
= cchString
;
1472 TRACE("(%s, %d)\n", debugstr_w(pszString
), cchString
);
1474 if ((cchString
< MAXLONG
) && (dst
= heap_alloc(cchString
* sizeof(WCHAR
))))
1476 len
= ExpandEnvironmentStringsW(pszString
, dst
, cchString
);
1477 /* len includes the terminating 0 */
1478 if (len
&& len
<= cchString
)
1481 memcpy(pszString
, dst
, len
* sizeof(WCHAR
));
1488 return MAKELONG(len
, res
);
1491 /************************************************************************
1492 * DoEnvironmentSubst [SHELL32.53]
1494 * See DoEnvironmentSubstA.
1496 DWORD WINAPI
DoEnvironmentSubstAW(LPVOID x
, UINT y
)
1498 if (SHELL_OsIsUnicode())
1499 return DoEnvironmentSubstW(x
, y
);
1500 return DoEnvironmentSubstA(x
, y
);
1503 /*************************************************************************
1506 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1507 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1511 BOOL WINAPI
shell32_243(DWORD a
, DWORD b
)
1516 /*************************************************************************
1517 * GUIDFromStringW [SHELL32.704]
1519 BOOL WINAPI
GUIDFromStringW(LPCWSTR str
, LPGUID guid
)
1521 UNICODE_STRING guid_str
;
1523 RtlInitUnicodeString(&guid_str
, str
);
1524 return !RtlGUIDFromString(&guid_str
, guid
);
1527 /*************************************************************************
1528 * PathIsTemporaryW [SHELL32.714]
1530 BOOL WINAPI
PathIsTemporaryW(const WCHAR
*path
)
1532 FIXME("(%s) stub\n", debugstr_w(path
));
1536 typedef struct _PSXA
1540 IShellPropSheetExt
*pspsx
[1];
1543 typedef struct _PSXA_CALL
1545 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith
;
1550 } PSXA_CALL
, *PPSXA_CALL
;
1552 static BOOL CALLBACK
PsxaCall(HPROPSHEETPAGE hpage
, LPARAM lParam
)
1554 PPSXA_CALL Call
= (PPSXA_CALL
)lParam
;
1558 if ((Call
->bMultiple
|| !Call
->bCalled
) &&
1559 Call
->lpfnAddReplaceWith(hpage
, Call
->lParam
))
1561 Call
->bCalled
= TRUE
;
1570 /*************************************************************************
1571 * SHAddFromPropSheetExtArray [SHELL32.167]
1573 UINT WINAPI
SHAddFromPropSheetExtArray(HPSXA hpsxa
, LPFNADDPROPSHEETPAGE lpfnAddPage
, LPARAM lParam
)
1577 PPSXA psxa
= (PPSXA
)hpsxa
;
1579 TRACE("(%p,%p,%08Ix)\n", hpsxa
, lpfnAddPage
, lParam
);
1583 ZeroMemory(&Call
, sizeof(Call
));
1584 Call
.lpfnAddReplaceWith
= lpfnAddPage
;
1585 Call
.lParam
= lParam
;
1586 Call
.bMultiple
= TRUE
;
1588 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1589 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1591 IShellPropSheetExt_AddPages(psxa
->pspsx
[i
], PsxaCall
, (LPARAM
)&Call
);
1594 return Call
.uiCount
;
1600 /*************************************************************************
1601 * SHCreatePropSheetExtArray [SHELL32.168]
1603 HPSXA WINAPI
SHCreatePropSheetExtArray(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
)
1605 return SHCreatePropSheetExtArrayEx(hKey
, pszSubKey
, max_iface
, NULL
);
1608 /*************************************************************************
1609 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1611 HPSXA WINAPI
SHCreatePropSheetExtArrayEx(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
, LPDATAOBJECT pDataObj
)
1613 WCHAR szHandler
[64];
1615 WCHAR szClsidHandler
[39];
1620 IShellExtInit
*psxi
;
1621 IShellPropSheetExt
*pspsx
;
1622 HKEY hkBase
, hkPropSheetHandlers
;
1625 TRACE("(%p,%s,%u)\n", hKey
, debugstr_w(pszSubKey
), max_iface
);
1630 /* Open the registry key */
1631 lRet
= RegOpenKeyW(hKey
, pszSubKey
, &hkBase
);
1632 if (lRet
!= ERROR_SUCCESS
)
1635 lRet
= RegOpenKeyExW(hkBase
, L
"shellex\\PropertySheetHandlers", 0, KEY_ENUMERATE_SUB_KEYS
, &hkPropSheetHandlers
);
1636 RegCloseKey(hkBase
);
1637 if (lRet
== ERROR_SUCCESS
)
1639 /* Create and initialize the Property Sheet Extensions Array */
1640 psxa
= LocalAlloc(LMEM_FIXED
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1643 ZeroMemory(psxa
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1644 psxa
->uiAllocated
= max_iface
;
1646 /* Enumerate all subkeys and attempt to load the shell extensions */
1650 dwHandlerLen
= ARRAY_SIZE(szHandler
);
1651 lRet
= RegEnumKeyExW(hkPropSheetHandlers
, dwIndex
++, szHandler
, &dwHandlerLen
, NULL
, NULL
, NULL
, NULL
);
1652 if (lRet
!= ERROR_SUCCESS
)
1654 if (lRet
== ERROR_MORE_DATA
)
1657 if (lRet
== ERROR_NO_MORE_ITEMS
)
1658 lRet
= ERROR_SUCCESS
;
1662 /* The CLSID is stored either in the key itself or in its default value. */
1663 if (FAILED(lRet
= SHCLSIDFromStringW(szHandler
, &clsid
)))
1665 dwClsidSize
= sizeof(szClsidHandler
);
1666 if (SHGetValueW(hkPropSheetHandlers
, szHandler
, NULL
, NULL
, szClsidHandler
, &dwClsidSize
) == ERROR_SUCCESS
)
1668 /* Force a NULL-termination and convert the string */
1669 szClsidHandler
[ARRAY_SIZE(szClsidHandler
) - 1] = 0;
1670 lRet
= SHCLSIDFromStringW(szClsidHandler
, &clsid
);
1674 if (SUCCEEDED(lRet
))
1676 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1677 Only if both interfaces are supported it's a real shell extension.
1678 Then call IShellExtInit's Initialize method. */
1679 if (SUCCEEDED(CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt
, (LPVOID
*)&pspsx
)))
1681 if (SUCCEEDED(IShellPropSheetExt_QueryInterface(pspsx
, &IID_IShellExtInit
, (PVOID
*)&psxi
)))
1683 if (SUCCEEDED(IShellExtInit_Initialize(psxi
, NULL
, pDataObj
, hKey
)))
1685 /* Add the IShellPropSheetExt instance to the array */
1686 psxa
->pspsx
[psxa
->uiCount
++] = pspsx
;
1690 IShellExtInit_Release(psxi
);
1691 IShellPropSheetExt_Release(pspsx
);
1695 IShellPropSheetExt_Release(pspsx
);
1699 } while (psxa
->uiCount
!= psxa
->uiAllocated
);
1702 lRet
= ERROR_NOT_ENOUGH_MEMORY
;
1704 RegCloseKey(hkPropSheetHandlers
);
1707 if (lRet
!= ERROR_SUCCESS
&& psxa
)
1709 SHDestroyPropSheetExtArray((HPSXA
)psxa
);
1716 /*************************************************************************
1717 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1719 UINT WINAPI
SHReplaceFromPropSheetExtArray(HPSXA hpsxa
, UINT uPageID
, LPFNADDPROPSHEETPAGE lpfnReplaceWith
, LPARAM lParam
)
1723 PPSXA psxa
= (PPSXA
)hpsxa
;
1725 TRACE("(%p,%u,%p,%08Ix)\n", hpsxa
, uPageID
, lpfnReplaceWith
, lParam
);
1729 ZeroMemory(&Call
, sizeof(Call
));
1730 Call
.lpfnAddReplaceWith
= lpfnReplaceWith
;
1731 Call
.lParam
= lParam
;
1733 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1734 Each shell extension is only allowed to call the callback once during the callback. */
1735 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1737 Call
.bCalled
= FALSE
;
1738 IShellPropSheetExt_ReplacePage(psxa
->pspsx
[i
], uPageID
, PsxaCall
, (LPARAM
)&Call
);
1741 return Call
.uiCount
;
1747 /*************************************************************************
1748 * SHDestroyPropSheetExtArray [SHELL32.169]
1750 void WINAPI
SHDestroyPropSheetExtArray(HPSXA hpsxa
)
1753 PPSXA psxa
= (PPSXA
)hpsxa
;
1755 TRACE("(%p)\n", hpsxa
);
1759 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1761 IShellPropSheetExt_Release(psxa
->pspsx
[i
]);
1768 /*************************************************************************
1769 * CIDLData_CreateFromIDArray [SHELL32.83]
1771 * Create IDataObject from PIDLs??
1773 HRESULT WINAPI
CIDLData_CreateFromIDArray(
1774 LPCITEMIDLIST pidlFolder
,
1776 LPCITEMIDLIST
*lppidlFiles
,
1777 LPDATAOBJECT
*ppdataObject
)
1780 HWND hwnd
= 0; /*FIXME: who should be hwnd of owner? set to desktop */
1782 TRACE("(%p, %ld, %p, %p)\n", pidlFolder
, cpidlFiles
, lppidlFiles
, ppdataObject
);
1786 for (i
=0; i
<cpidlFiles
; i
++) pdump (lppidlFiles
[i
]);
1788 *ppdataObject
= IDataObject_Constructor( hwnd
, pidlFolder
,
1789 lppidlFiles
, cpidlFiles
);
1790 if (*ppdataObject
) return S_OK
;
1791 return E_OUTOFMEMORY
;
1794 /*************************************************************************
1795 * SHCreateStdEnumFmtEtc [SHELL32.74]
1800 HRESULT WINAPI
SHCreateStdEnumFmtEtc(
1802 const FORMATETC
*lpFormats
,
1803 LPENUMFORMATETC
*ppenumFormatetc
)
1805 IEnumFORMATETC
*pef
;
1807 TRACE("cf=%ld fe=%p pef=%p\n", cFormats
, lpFormats
, ppenumFormatetc
);
1809 pef
= IEnumFORMATETC_Constructor(cFormats
, lpFormats
);
1811 return E_OUTOFMEMORY
;
1813 IEnumFORMATETC_AddRef(pef
);
1814 hRes
= IEnumFORMATETC_QueryInterface(pef
, &IID_IEnumFORMATETC
, (LPVOID
*)ppenumFormatetc
);
1815 IEnumFORMATETC_Release(pef
);
1820 /*************************************************************************
1821 * SHFindFiles (SHELL32.90)
1823 BOOL WINAPI
SHFindFiles( LPCITEMIDLIST pidlFolder
, LPCITEMIDLIST pidlSaveFile
)
1825 FIXME("%p %p\n", pidlFolder
, pidlSaveFile
);
1829 /*************************************************************************
1830 * SHUpdateImageW (SHELL32.192)
1832 * Notifies the shell that an icon in the system image list has been changed.
1835 * pszHashItem [I] Path to file that contains the icon.
1836 * iIndex [I] Zero-based index of the icon in the file.
1837 * uFlags [I] Flags determining the icon attributes. See notes.
1838 * iImageIndex [I] Index of the icon in the system image list.
1844 * uFlags can be one or more of the following flags:
1845 * GIL_NOTFILENAME - pszHashItem is not a file name.
1846 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1848 void WINAPI
SHUpdateImageW(LPCWSTR pszHashItem
, int iIndex
, UINT uFlags
, int iImageIndex
)
1850 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1853 /*************************************************************************
1854 * SHUpdateImageA (SHELL32.191)
1856 * See SHUpdateImageW.
1858 VOID WINAPI
SHUpdateImageA(LPCSTR pszHashItem
, INT iIndex
, UINT uFlags
, INT iImageIndex
)
1860 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1863 INT WINAPI
SHHandleUpdateImage(LPCITEMIDLIST pidlExtra
)
1865 FIXME("%p - stub\n", pidlExtra
);
1870 BOOL WINAPI
SHObjectProperties(HWND hwnd
, DWORD dwType
, LPCWSTR szObject
, LPCWSTR szPage
)
1872 FIXME("%p, 0x%08lx, %s, %s - stub\n", hwnd
, dwType
, debugstr_w(szObject
), debugstr_w(szPage
));
1877 BOOL WINAPI
SHGetNewLinkInfoA(LPCSTR pszLinkTo
, LPCSTR pszDir
, LPSTR pszName
, BOOL
*pfMustCopy
,
1880 WCHAR wszLinkTo
[MAX_PATH
];
1881 WCHAR wszDir
[MAX_PATH
];
1882 WCHAR wszName
[MAX_PATH
];
1885 MultiByteToWideChar(CP_ACP
, 0, pszLinkTo
, -1, wszLinkTo
, MAX_PATH
);
1886 MultiByteToWideChar(CP_ACP
, 0, pszDir
, -1, wszDir
, MAX_PATH
);
1888 res
= SHGetNewLinkInfoW(wszLinkTo
, wszDir
, wszName
, pfMustCopy
, uFlags
);
1891 WideCharToMultiByte(CP_ACP
, 0, wszName
, -1, pszName
, MAX_PATH
, NULL
, NULL
);
1896 BOOL WINAPI
SHGetNewLinkInfoW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
, BOOL
*pfMustCopy
,
1899 const WCHAR
*basename
;
1900 WCHAR
*dst_basename
;
1903 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo
), debugstr_w(pszDir
),
1904 pszName
, pfMustCopy
, uFlags
);
1906 *pfMustCopy
= FALSE
;
1908 if (uFlags
& SHGNLI_PIDL
)
1910 FIXME("SHGNLI_PIDL flag unsupported\n");
1915 FIXME("ignoring flags: 0x%08x\n", uFlags
);
1917 /* FIXME: should test if the file is a shortcut or DOS program */
1918 if (GetFileAttributesW(pszLinkTo
) == INVALID_FILE_ATTRIBUTES
)
1921 basename
= wcsrchr(pszLinkTo
, '\\');
1923 basename
= basename
+1;
1925 basename
= pszLinkTo
;
1927 lstrcpynW(pszName
, pszDir
, MAX_PATH
);
1928 if (!PathAddBackslashW(pszName
))
1931 dst_basename
= pszName
+ lstrlenW(pszName
);
1933 swprintf(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, L
"%s.lnk", basename
);
1935 while (GetFileAttributesW(pszName
) != INVALID_FILE_ATTRIBUTES
)
1937 swprintf(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, L
"%s (%d).lnk", basename
, i
);
1944 HRESULT WINAPI
SHStartNetConnectionDialog(HWND hwnd
, LPCSTR pszRemoteName
, DWORD dwType
)
1946 FIXME("%p, %s, 0x%08lx - stub\n", hwnd
, debugstr_a(pszRemoteName
), dwType
);
1951 DWORD WINAPI
SHFormatDrive(HWND hwnd
, UINT drive
, UINT fmtID
, UINT options
)
1953 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd
, drive
, fmtID
, options
);
1955 return SHFMT_NOFORMAT
;
1958 /*************************************************************************
1959 * SHRemoveLocalizedName (SHELL32.@)
1961 HRESULT WINAPI
SHRemoveLocalizedName(const WCHAR
*path
)
1963 FIXME("%s stub\n", debugstr_w(path
));
1967 /*************************************************************************
1968 * SHSetLocalizedName (SHELL32.@)
1970 HRESULT WINAPI
SHSetLocalizedName(LPWSTR pszPath
, LPCWSTR pszResModule
, int idsRes
)
1972 FIXME("%p, %s, %d - stub\n", pszPath
, debugstr_w(pszResModule
), idsRes
);
1977 /*************************************************************************
1978 * LinkWindow_RegisterClass (SHELL32.258)
1980 BOOL WINAPI
LinkWindow_RegisterClass(void)
1986 /*************************************************************************
1987 * LinkWindow_UnregisterClass (SHELL32.259)
1989 BOOL WINAPI
LinkWindow_UnregisterClass(void)
1995 /*************************************************************************
1996 * SHFlushSFCache (SHELL32.526)
1998 * Notifies the shell that a user-specified special folder location has changed.
2001 * In Wine, the shell folder registry values are not cached, so this function
2004 void WINAPI
SHFlushSFCache(void)