2 * The parameters of many functions changes between different OS versions
3 * (NT uses Unicode strings, 95 uses ASCII strings)
5 * Copyright 1997 Marcus Meissner
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <wine/config.h>
25 #define WIN32_NO_STATUS
31 #include <wine/winternl.h>
33 #include <undocshell.h>
36 #include <commoncontrols.h>
37 #include "../shellrecyclebin/recyclebin.h"
39 #include <wine/debug.h>
40 #include <wine/unicode.h>
43 #include "shell32_main.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
46 WINE_DECLARE_DEBUG_CHANNEL(pidl
);
49 #include <comctl32_undoc.h>
51 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
52 /* !!! it is in both here and comctl32undoc.c !!! */
53 typedef struct tagCREATEMRULIST
55 DWORD cbSize
; /* size of struct */
56 DWORD nMaxItems
; /* max no. of items in list */
57 DWORD dwFlags
; /* see below */
58 HKEY hKey
; /* root reg. key under which list is saved */
59 LPCSTR lpszSubKey
; /* reg. subkey */
60 int (CALLBACK
*lpfnCompare
)(LPCVOID
, LPCVOID
, DWORD
); /* item compare proc */
61 } CREATEMRULISTA
, *LPCREATEMRULISTA
;
64 #define MRUF_STRING_LIST 0 /* list will contain strings */
65 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
66 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
68 extern HANDLE WINAPI
CreateMRUListA(LPCREATEMRULISTA lpcml
);
69 extern VOID WINAPI
FreeMRUList(HANDLE hMRUList
);
70 extern INT WINAPI
AddMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
71 extern INT WINAPI
FindMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
72 extern INT WINAPI
EnumMRUListA(HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
75 /*************************************************************************
76 * ParseFieldA [internal]
78 * copies a field from a ',' delimited string
80 * first field is nField = 1
82 DWORD WINAPI
ParseFieldA(
88 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src
),nField
,dst
,len
);
90 if (!src
|| !src
[0] || !dst
|| !len
)
93 /* skip n fields delimited by ',' */
96 if (*src
=='\0') return FALSE
;
97 if (*(src
++)==',') nField
--;
100 /* copy part till the next ',' to dst */
101 while ( *src
!='\0' && *src
!=',' && (len
--)>0 ) *(dst
++)=*(src
++);
103 /* finalize the string */
109 /*************************************************************************
110 * ParseFieldW [internal]
112 * copies a field from a ',' delimited string
114 * first field is nField = 1
116 DWORD WINAPI
ParseFieldW(LPCWSTR src
, DWORD nField
, LPWSTR dst
, DWORD len
)
118 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src
), nField
, dst
, len
);
120 if (!src
|| !src
[0] || !dst
|| !len
)
123 /* skip n fields delimited by ',' */
126 if (*src
== 0x0) return FALSE
;
127 if (*src
++ == ',') nField
--;
130 /* copy part till the next ',' to dst */
131 while ( *src
!= 0x0 && *src
!= ',' && (len
--)>0 ) *(dst
++) = *(src
++);
133 /* finalize the string */
139 /*************************************************************************
140 * ParseField [SHELL32.58]
142 DWORD WINAPI
ParseFieldAW(LPCVOID src
, DWORD nField
, LPVOID dst
, DWORD len
)
144 if (SHELL_OsIsUnicode())
145 return ParseFieldW(src
, nField
, dst
, len
);
146 return ParseFieldA(src
, nField
, dst
, len
);
149 /*************************************************************************
150 * GetFileNameFromBrowse [SHELL32.63]
153 BOOL WINAPI
GetFileNameFromBrowse(
157 LPCWSTR lpstrInitialDir
,
162 typedef BOOL (WINAPI
*GetOpenFileNameProc
)(OPENFILENAMEW
*ofn
);
164 GetOpenFileNameProc pGetOpenFileNameW
;
168 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
169 hwndOwner
, debugstr_w(lpstrFile
), nMaxFile
, lpstrInitialDir
, lpstrDefExt
,
170 lpstrFilter
, lpstrTitle
);
172 hmodule
= LoadLibraryW(L
"comdlg32.dll");
173 if(!hmodule
) return FALSE
;
174 pGetOpenFileNameW
= (GetOpenFileNameProc
)GetProcAddress(hmodule
, "GetOpenFileNameW");
175 if(!pGetOpenFileNameW
)
177 FreeLibrary(hmodule
);
181 memset(&ofn
, 0, sizeof(ofn
));
183 ofn
.lStructSize
= sizeof(ofn
);
184 ofn
.hwndOwner
= hwndOwner
;
185 ofn
.lpstrFilter
= lpstrFilter
;
186 ofn
.lpstrFile
= lpstrFile
;
187 ofn
.nMaxFile
= nMaxFile
;
188 ofn
.lpstrInitialDir
= lpstrInitialDir
;
189 ofn
.lpstrTitle
= lpstrTitle
;
190 ofn
.lpstrDefExt
= lpstrDefExt
;
191 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
192 ret
= pGetOpenFileNameW(&ofn
);
194 FreeLibrary(hmodule
);
198 /*************************************************************************
199 * SHGetSetSettings [SHELL32.68]
201 VOID WINAPI
SHGetSetSettings(LPSHELLSTATE lpss
, DWORD dwMask
, BOOL bSet
)
205 FIXME("%p 0x%08x TRUE\n", lpss
, dwMask
);
209 SHGetSettings((LPSHELLFLAGSTATE
)lpss
,dwMask
);
213 /*************************************************************************
214 * SHGetSettings [SHELL32.@]
217 * the registry path are for win98 (tested)
218 * and possibly are the same in nt40
221 VOID WINAPI
SHGetSettings(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
)
225 DWORD dwDataSize
= sizeof (DWORD
);
227 TRACE("(%p 0x%08x)\n",lpsfs
,dwMask
);
229 if (RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
230 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0))
233 if ( (SSF_SHOWEXTENSIONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideFileExt", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
234 lpsfs
->fShowExtensions
= ((dwData
== 0) ? 0 : 1);
236 if ( (SSF_SHOWINFOTIP
& dwMask
) && !RegQueryValueExA(hKey
, "ShowInfoTip", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
237 lpsfs
->fShowInfoTip
= ((dwData
== 0) ? 0 : 1);
239 if ( (SSF_DONTPRETTYPATH
& dwMask
) && !RegQueryValueExA(hKey
, "DontPrettyPath", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
240 lpsfs
->fDontPrettyPath
= ((dwData
== 0) ? 0 : 1);
242 if ( (SSF_HIDEICONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideIcons", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
243 lpsfs
->fHideIcons
= ((dwData
== 0) ? 0 : 1);
245 if ( (SSF_MAPNETDRVBUTTON
& dwMask
) && !RegQueryValueExA(hKey
, "MapNetDrvBtn", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
246 lpsfs
->fMapNetDrvBtn
= ((dwData
== 0) ? 0 : 1);
248 if ( (SSF_SHOWATTRIBCOL
& dwMask
) && !RegQueryValueExA(hKey
, "ShowAttribCol", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
249 lpsfs
->fShowAttribCol
= ((dwData
== 0) ? 0 : 1);
251 if (((SSF_SHOWALLOBJECTS
| SSF_SHOWSYSFILES
) & dwMask
) && !RegQueryValueExA(hKey
, "Hidden", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
253 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
254 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
256 else if (dwData
== 1)
257 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 1;
258 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
260 else if (dwData
== 2)
261 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
262 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 1;
267 TRACE("-- 0x%04x\n", *(WORD
*)lpsfs
);
270 /*************************************************************************
271 * SHShellFolderView_Message [SHELL32.73]
273 * Send a message to an explorer cabinet window.
276 * hwndCabinet [I] The window containing the shellview to communicate with
277 * dwMessage [I] The SFVM message to send
278 * dwParam [I] Message parameter
284 * Message SFVM_REARRANGE = 1
286 * This message gets sent when a column gets clicked to instruct the
287 * shell view to re-sort the item list. dwParam identifies the column
290 LRESULT WINAPI
SHShellFolderView_Message(
295 FIXME("%p %08x %08lx stub\n",hwndCabinet
, uMessage
, lParam
);
299 /*************************************************************************
300 * RegisterShellHook [SHELL32.181]
302 * Register a shell hook.
305 * hwnd [I] Window handle
306 * dwType [I] Type of hook.
309 * Exported by ordinal
311 BOOL WINAPI
RegisterShellHook(
317 SetTaskmanWindow(hWnd
);
318 return RegisterShellHookWindow(hWnd
);
320 else if (dwType
== 0)
322 return DeregisterShellHookWindow(hWnd
);
325 ERR("Unsupported argument");
329 /*************************************************************************
330 * ShellMessageBoxW [SHELL32.182]
332 * See ShellMessageBoxA.
335 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
336 * because we can't forward to it in the .spec file since it's exported by
337 * ordinal. If you change the implementation here please update the code in
340 int ShellMessageBoxW(
348 WCHAR szText
[100],szTitle
[100];
349 LPCWSTR pszText
= szText
, pszTitle
= szTitle
;
354 __ms_va_start(args
, uType
);
355 /* wvsprintfA(buf,fmt, args); */
357 TRACE("(%p,%p,%p,%p,%08x)\n",
358 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
360 if (IS_INTRESOURCE(lpCaption
))
361 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]));
363 pszTitle
= lpCaption
;
365 if (IS_INTRESOURCE(lpText
))
366 LoadStringW(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
)/sizeof(szText
[0]));
370 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
371 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
375 ret
= MessageBoxW(hWnd
,pszTemp
,pszTitle
,uType
);
380 /*************************************************************************
381 * ShellMessageBoxA [SHELL32.183]
383 * Format and output an error message.
386 * hInstance [I] Instance handle of message creator
387 * hWnd [I] Window handle of message creator
388 * lpText [I] Resource Id of title or LPSTR
389 * lpCaption [I] Resource Id of title or LPSTR
390 * uType [I] Type of error message
393 * A return value from MessageBoxA().
396 * Exported by ordinal
398 int ShellMessageBoxA(
406 char szText
[100],szTitle
[100];
407 LPCSTR pszText
= szText
, pszTitle
= szTitle
;
412 __ms_va_start(args
, uType
);
413 /* wvsprintfA(buf,fmt, args); */
415 TRACE("(%p,%p,%p,%p,%08x)\n",
416 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
418 if (IS_INTRESOURCE(lpCaption
))
419 LoadStringA(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
));
421 pszTitle
= lpCaption
;
423 if (IS_INTRESOURCE(lpText
))
424 LoadStringA(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
));
428 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
429 pszText
, 0, 0, (LPSTR
)&pszTemp
, 0, &args
);
433 ret
= MessageBoxA(hWnd
,pszTemp
,pszTitle
,uType
);
438 /*************************************************************************
439 * SHRegisterDragDrop [SHELL32.86]
441 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
442 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
443 * for details. Under Windows 98 this function initializes the true OLE when called
444 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
446 * We follow Windows 98 behaviour.
449 * exported by ordinal
452 * RegisterDragDrop, SHLoadOLE
454 HRESULT WINAPI
SHRegisterDragDrop(
456 LPDROPTARGET pDropTarget
)
458 static BOOL ole_initialized
= FALSE
;
461 TRACE("(%p,%p)\n", hWnd
, pDropTarget
);
463 if (!ole_initialized
)
465 hr
= OleInitialize(NULL
);
468 ole_initialized
= TRUE
;
470 return RegisterDragDrop(hWnd
, pDropTarget
);
473 /*************************************************************************
474 * SHRevokeDragDrop [SHELL32.87]
476 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
477 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
478 * for details. Function removed from Windows Vista.
480 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
484 * exported by ordinal
487 * RevokeDragDrop, SHLoadOLE
489 HRESULT WINAPI
SHRevokeDragDrop(HWND hWnd
)
491 TRACE("(%p)\n", hWnd
);
492 return RevokeDragDrop(hWnd
);
495 /*************************************************************************
496 * SHDoDragDrop [SHELL32.88]
498 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
499 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
503 * exported by ordinal
506 * DoDragDrop, SHLoadOLE
508 HRESULT WINAPI
SHDoDragDrop(
510 LPDATAOBJECT lpDataObject
,
511 LPDROPSOURCE lpDropSource
,
515 FIXME("(%p %p %p 0x%08x %p):stub.\n",
516 hWnd
, lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
517 return DoDragDrop(lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
520 /*************************************************************************
521 * ArrangeWindows [SHELL32.184]
524 WORD WINAPI
ArrangeWindows(HWND hwndParent
, DWORD dwReserved
, const RECT
*lpRect
,
525 WORD cKids
, const HWND
*lpKids
)
527 /* Unimplemented in WinXP SP3 */
528 TRACE("(%p 0x%08x %p 0x%04x %p):stub.\n",
529 hwndParent
, dwReserved
, lpRect
, cKids
, lpKids
);
533 /*************************************************************************
534 * SignalFileOpen [SHELL32.103]
537 * exported by ordinal
540 SignalFileOpen (PCIDLIST_ABSOLUTE pidl
)
542 FIXME("(%p):stub.\n", pidl
);
547 /*************************************************************************
548 * SHADD_get_policy - helper function for SHAddToRecentDocs
551 * policy [IN] policy name (null termed string) to find
552 * type [OUT] ptr to DWORD to receive type
553 * buffer [OUT] ptr to area to hold data retrieved
554 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
558 * result of the SHQueryValueEx call
560 static INT
SHADD_get_policy(LPCSTR policy
, LPDWORD type
, LPVOID buffer
, LPDWORD len
)
565 /* Get the key for the policies location in the registry
567 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
568 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
569 0, KEY_READ
, &Policy_basekey
)) {
571 if (RegOpenKeyExA(HKEY_CURRENT_USER
,
572 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
573 0, KEY_READ
, &Policy_basekey
)) {
574 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
577 return ERROR_FILE_NOT_FOUND
;
581 /* Retrieve the data if it exists
583 ret
= SHQueryValueExA(Policy_basekey
, policy
, 0, type
, buffer
, len
);
584 RegCloseKey(Policy_basekey
);
589 /*************************************************************************
590 * SHADD_compare_mru - helper function for SHAddToRecentDocs
593 * data1 [IN] data being looked for
594 * data2 [IN] data in MRU
595 * cbdata [IN] length from FindMRUData call (not used)
598 * position within MRU list that data was added.
600 static INT CALLBACK
SHADD_compare_mru(LPCVOID data1
, LPCVOID data2
, DWORD cbData
)
604 INT iCmp
= lstrcmpiW(data1
, data2
);
609 psz1
+= lstrlenW(psz1
) + 1;
610 psz2
+= lstrlenW(psz2
) + 1;
611 return lstrcmpiW(psz1
, psz2
);
613 return lstrcmpiA(data1
, data2
);
619 DoStoreMRUData(LPBYTE pbBuffer
, LPDWORD pcbBuffer
,
620 LPCWSTR pszTargetTitle
, LPCWSTR pszTargetPath
, LPCWSTR pszLinkTitle
)
623 INT cchTargetTitle
= lstrlenW(pszTargetTitle
);
624 INT cchTargetPath
= lstrlenW(pszTargetPath
);
625 INT cchLinkTitle
= lstrlenW(pszLinkTitle
);
627 cb
= (cchTargetTitle
+ 1 + cchTargetPath
+ 1 + cchLinkTitle
+ 2) * sizeof(WCHAR
);
631 ZeroMemory(pbBuffer
, *pcbBuffer
);
633 cb
= (cchTargetTitle
+ 1) * sizeof(WCHAR
);
634 if (ib
+ cb
> *pcbBuffer
)
636 CopyMemory(&pbBuffer
[ib
], pszTargetTitle
, cb
);
639 cb
= (cchTargetPath
+ 1) * sizeof(WCHAR
);
640 if (ib
+ cb
> *pcbBuffer
)
642 CopyMemory(&pbBuffer
[ib
], pszTargetPath
, cb
);
645 cb
= (cchLinkTitle
+ 1) * sizeof(WCHAR
);
646 if (ib
+ cb
> *pcbBuffer
)
648 CopyMemory(&pbBuffer
[ib
], pszLinkTitle
, cb
);
655 /*************************************************************************
656 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
659 * mruhandle [IN] handle for created MRU list
660 * doc_name [IN] null termed pure doc name
661 * new_lnk_name [IN] null termed path and file name for .lnk file
662 * buffer [IN/OUT] 2048 byte area to construct MRU data
663 * len [OUT] ptr to int to receive space used in buffer
666 * position within MRU list that data was added.
668 static INT
SHADD_create_add_mru_data(HANDLE mruhandle
, LPCSTR doc_name
, LPCSTR new_lnk_name
,
669 LPSTR buffer
, INT
*len
)
675 * RecentDocs MRU data structure seems to be:
676 * +0h document file name w/ terminating 0h
677 * +nh short int w/ size of remaining
678 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
679 * +n+4h 10 bytes zeros - unknown
680 * +n+eh shortcut file name w/ terminating 0h
681 * +n+e+nh 3 zero bytes - unknown
684 /* Create the MRU data structure for "RecentDocs"
687 lstrcpyA(ptr
, doc_name
);
688 ptr
+= (lstrlenA(buffer
) + 1);
689 wlen
= lstrlenA(new_lnk_name
) + 1 + 12;
690 *((short int*)ptr
) = wlen
;
691 ptr
+= 2; /* step past the length */
692 *(ptr
++) = 0x30; /* unknown reason */
693 *(ptr
++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
696 lstrcpyA(ptr
, new_lnk_name
);
697 ptr
+= (lstrlenA(new_lnk_name
) + 1);
702 /* Add the new entry into the MRU list
704 return AddMRUData(mruhandle
, buffer
, *len
);
708 /*************************************************************************
709 * SHAddToRecentDocs [SHELL32.@]
711 * Modify (add/clear) Shell's list of recently used documents.
714 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
715 * pv [IN] string or pidl, NULL clears the list
723 void WINAPI
SHAddToRecentDocs (UINT uFlags
,LPCVOID pv
)
726 static const WCHAR szExplorerKey
[] = L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer";
728 WCHAR szTargetPath
[MAX_PATH
], szLinkDir
[MAX_PATH
], szLinkFile
[MAX_PATH
], szDescription
[80];
729 WCHAR szPath
[MAX_PATH
];
730 DWORD cbBuffer
, data
[64], datalen
, type
;
732 WIN32_FIND_DATAW find
;
735 LPWSTR pchDotExt
, pchTargetTitle
, pchLinkTitle
;
737 HANDLE hMRUList
= NULL
;
738 IShellLinkW
*psl
= NULL
;
739 IPersistFile
*pPf
= NULL
;
741 BYTE Buffer
[(MAX_PATH
+ 64) * sizeof(WCHAR
)];
743 TRACE("%04x %p\n", uFlags
, pv
);
746 ret
= SHADD_get_policy("NoRecentDocsHistory", &type
, data
, &datalen
);
747 if (ret
> 0 && ret
!= ERROR_FILE_NOT_FOUND
)
749 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret
);
751 else if (ret
== ERROR_SUCCESS
)
753 if (!(type
== REG_DWORD
|| (type
== REG_BINARY
&& datalen
== 4)))
755 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
760 TRACE("policy value for NoRecentDocsHistory = %08x\n", data
[0]);
761 /* now test the actual policy value */
766 /* store to szTargetPath */
773 MultiByteToWideChar(CP_ACP
, 0, pv
, -1, szLinkDir
, ARRAYSIZE(szLinkDir
));
774 GetFullPathNameW(szLinkDir
, ARRAYSIZE(szTargetPath
), szTargetPath
, NULL
);
778 GetFullPathNameW(pv
, ARRAYSIZE(szTargetPath
), szTargetPath
, NULL
);
782 SHGetPathFromIDListW(pv
, szLinkDir
);
783 GetFullPathNameW(szLinkDir
, ARRAYSIZE(szTargetPath
), szTargetPath
, NULL
);
787 FIXME("Unsupported flags: %u\n", uFlags
);
792 /* get recent folder */
793 if (!SHGetSpecialFolderPathW(NULL
, szLinkDir
, CSIDL_RECENT
, FALSE
))
795 ERR("serious issues 1\n");
798 TRACE("Users Recent dir %S\n", szLinkDir
);
800 /* open Explorer key */
801 error
= RegCreateKeyExW(HKEY_CURRENT_USER
, szExplorerKey
, 0, NULL
, 0,
802 KEY_READ
| KEY_WRITE
, NULL
, &hExplorerKey
, NULL
);
805 ERR("Failed to RegCreateKeyExW: 0x%08X\n", error
);
811 TRACE("pv is NULL, so delete all shortcut files in %S\n", szLinkDir
);
813 lstrcpynW(szLinkFile
, szLinkDir
, ARRAYSIZE(szLinkFile
));
814 PathAppendW(szLinkFile
, L
"*.lnk");
816 hFind
= FindFirstFileW(szLinkFile
, &find
);
817 if (hFind
!= INVALID_HANDLE_VALUE
)
821 lstrcpynW(szLinkFile
, szLinkDir
, ARRAYSIZE(szLinkFile
));
822 PathAppendW(szLinkFile
, find
.cFileName
);
823 DeleteFileW(szLinkFile
);
824 } while (FindNextFile(hFind
, &find
));
828 SHDeleteKeyW(hExplorerKey
, L
"RecentDocs");
829 RegCloseKey(hExplorerKey
);
833 if (szTargetPath
[0] == 0 || !PathFileExistsW(szTargetPath
) ||
834 PathIsDirectoryW(szTargetPath
))
836 /* path is not normal file */
837 RegCloseKey(hExplorerKey
);
841 hr
= CoInitialize(NULL
);
844 ERR("CoInitialize: %08X\n", hr
);
845 RegCloseKey(hExplorerKey
);
849 /* check if file is a shortcut */
851 pchDotExt
= PathFindExtensionW(szTargetPath
);
852 while (lstrcmpiW(pchDotExt
, L
".lnk") == 0)
854 hr
= IShellLink_ConstructFromPath(szTargetPath
, &IID_IShellLinkW
, (LPVOID
*)&psl
);
857 ERR("IShellLink_ConstructFromPath: 0x%08X\n", hr
);
861 IShellLinkW_GetPath(psl
, szPath
, ARRAYSIZE(szPath
), NULL
, 0);
862 IShellLinkW_Release(psl
);
865 lstrcpynW(szTargetPath
, szPath
, ARRAYSIZE(szTargetPath
));
866 pchDotExt
= PathFindExtensionW(szTargetPath
);
874 if (!lstrcmpiW(pchDotExt
, L
".exe"))
876 /* executables are not added */
880 /* *** JOB 0: Build strings *** */
882 pchTargetTitle
= PathFindFileNameW(szTargetPath
);
884 lstrcpyW(szDescription
, L
"Shortcut to ");
885 StrCatBuffW(szDescription
, pchTargetTitle
, ARRAYSIZE(szDescription
));
887 lstrcpynW(szLinkFile
, szLinkDir
, ARRAYSIZE(szLinkFile
));
888 PathAppendW(szLinkFile
, pchTargetTitle
);
889 StrCatBuffW(szLinkFile
, L
".lnk", ARRAYSIZE(szLinkFile
));
890 pchLinkTitle
= PathFindFileNameW(szLinkFile
);
892 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
895 cbBuffer
= sizeof(Buffer
);
896 ret
= DoStoreMRUData(Buffer
, &cbBuffer
, pchTargetTitle
, szTargetPath
, pchLinkTitle
);
899 ERR("DoStoreMRUData failed: %d\n", ret
);
903 /* create MRU list */
904 mru
.cbSize
= sizeof(mru
);
906 mru
.fFlags
= MRU_BINARY
| MRU_CACHEWRITE
;
907 mru
.hKey
= hExplorerKey
;
908 mru
.lpszSubKey
= L
"RecentDocs";
909 mru
.lpfnCompare
= (MRUCMPPROCW
)SHADD_compare_mru
;
910 hMRUList
= CreateMRUListW(&mru
);
913 ERR("CreateMRUListW failed\n");
917 /* already exists? */
918 ret
= FindMRUData(hMRUList
, Buffer
, cbBuffer
, NULL
);
921 /* Just touch for speed */
923 hFile
= CreateFileW(szLinkFile
, GENERIC_READ
| GENERIC_WRITE
,
924 FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, NULL
);
925 if (hFile
!= INVALID_HANDLE_VALUE
)
927 TRACE("Just touch file '%S'.\n", szLinkFile
);
934 ret
= AddMRUData(hMRUList
, Buffer
, cbBuffer
);
937 ERR("AddMRUData failed: %d\n", ret
);
941 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
943 hr
= CoCreateInstance(&CLSID_ShellLink
, NULL
, CLSCTX_INPROC_SERVER
,
944 &IID_IShellLinkW
, (LPVOID
*)&psl
);
947 ERR("CoInitialize for IID_IShellLinkW: %08X\n", hr
);
951 hr
= IShellLinkW_QueryInterface(psl
, &IID_IPersistFile
, (LPVOID
*)&pPf
);
954 ERR("IShellLinkW_QueryInterface: %08X\n", hr
);
958 if (uFlags
== SHARD_PIDL
)
959 hr
= IShellLinkW_SetIDList(psl
, pv
);
961 hr
= IShellLinkW_SetPath(psl
, pv
);
963 IShellLinkW_SetDescription(psl
, szDescription
);
965 hr
= IPersistFile_Save(pPf
, szLinkFile
, TRUE
);
968 ERR("IPersistFile_Save: 0x%08X\n", hr
);
971 hr
= IPersistFile_SaveCompleted(pPf
, szLinkFile
);
974 ERR("IPersistFile_SaveCompleted: 0x%08X\n", hr
);
979 FreeMRUList(hMRUList
);
981 IPersistFile_Release(pPf
);
983 IShellLinkW_Release(psl
);
985 RegCloseKey(hExplorerKey
);
987 /* If list is a string list lpfnCompare has the following prototype
988 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
989 * for binary lists the prototype is
990 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
991 * where cbData is the no. of bytes to compare.
992 * Need to check what return value means identical - 0?
998 CHAR doc_name
[MAX_PATH
];
999 CHAR link_dir
[MAX_PATH
];
1000 CHAR new_lnk_filepath
[MAX_PATH
];
1001 CHAR new_lnk_name
[MAX_PATH
];
1005 HWND hwnd
= 0; /* FIXME: get real window handle */
1007 DWORD data
[64], datalen
, type
;
1009 TRACE("%04x %p\n", uFlags
, pv
);
1012 * RecentDocs MRU data structure seems to be:
1013 * +0h document file name w/ terminating 0h
1014 * +nh short int w/ size of remaining
1015 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
1016 * +n+4h 10 bytes zeros - unknown
1017 * +n+eh shortcut file name w/ terminating 0h
1018 * +n+e+nh 3 zero bytes - unknown
1021 /* See if we need to do anything.
1024 ret
=SHADD_get_policy( "NoRecentDocsHistory", &type
, data
, &datalen
);
1025 if ((ret
> 0) && (ret
!= ERROR_FILE_NOT_FOUND
)) {
1026 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret
);
1029 if (ret
== ERROR_SUCCESS
) {
1030 if (!( (type
== REG_DWORD
) ||
1031 ((type
== REG_BINARY
) && (datalen
== 4)) )) {
1032 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
1037 TRACE("policy value for NoRecentDocsHistory = %08x\n", data
[0]);
1038 /* now test the actual policy value */
1043 /* Open key to where the necessary info is
1045 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
1046 * and the close should be done during the _DETACH. The resulting
1047 * key is stored in the DLL global data.
1049 if (RegCreateKeyExA(HKEY_CURRENT_USER
,
1050 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
1051 0, 0, 0, KEY_READ
, 0, &HCUbasekey
, 0)) {
1052 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
1056 /* Get path to user's "Recent" directory
1058 if(SUCCEEDED(SHGetMalloc(&ppM
))) {
1059 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd
, CSIDL_RECENT
,
1061 SHGetPathFromIDListA(pidl
, link_dir
);
1062 IMalloc_Free(ppM
, pidl
);
1065 /* serious issues */
1067 ERR("serious issues 1\n");
1069 IMalloc_Release(ppM
);
1072 /* serious issues */
1074 ERR("serious issues 2\n");
1076 TRACE("Users Recent dir %s\n", link_dir
);
1078 /* If no input, then go clear the lists */
1080 /* clear user's Recent dir
1083 /* FIXME: delete all files in "link_dir"
1085 * while( more files ) {
1086 * lstrcpyA(old_lnk_name, link_dir);
1087 * PathAppendA(old_lnk_name, filenam);
1088 * DeleteFileA(old_lnk_name);
1091 FIXME("should delete all files in %s\\\n", link_dir
);
1095 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
1096 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
1097 * and naturally it fails w/ rc=2. It should do it against
1098 * HKEY_CURRENT_USER which is where it is stored, and where
1099 * the MRU routines expect it!!!!
1101 RegDeleteKeyA(HCUbasekey
, "RecentDocs");
1102 RegCloseKey(HCUbasekey
);
1106 /* Have data to add, the jobs to be done:
1107 * 1. Add document to MRU list in registry "HKCU\Software\
1108 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
1109 * 2. Add shortcut to document in the user's Recent directory
1111 * 3. Add shortcut to Start menu's Documents submenu.
1114 /* Get the pure document name from the input
1119 if (!SHGetPathFromIDListA(pv
, doc_name
))
1121 WARN("can't get path from PIDL\n");
1127 lstrcpynA(doc_name
, pv
, MAX_PATH
);
1131 WideCharToMultiByte(CP_ACP
, 0, pv
, -1, doc_name
, MAX_PATH
, NULL
, NULL
);
1135 FIXME("Unsupported flags: %u\n", uFlags
);
1139 TRACE("full document name %s\n", debugstr_a(doc_name
));
1141 PathStripPathA(doc_name
);
1142 TRACE("stripped document name %s\n", debugstr_a(doc_name
));
1145 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
1147 { /* on input needs:
1148 * doc_name - pure file-spec, no path
1149 * link_dir - path to the user's Recent directory
1150 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
1152 * new_lnk_name- pure file-spec, no path for new .lnk file
1154 * - path and file name of new .lnk file
1156 CREATEMRULISTA mymru
;
1158 INT len
, pos
, bufused
, err
;
1163 CHAR old_lnk_name
[MAX_PATH
];
1166 mymru
.cbSize
= sizeof(CREATEMRULISTA
);
1167 mymru
.nMaxItems
= 15;
1168 mymru
.dwFlags
= MRUF_BINARY_LIST
| MRUF_DELAYED_SAVE
;
1169 mymru
.hKey
= HCUbasekey
;
1170 mymru
.lpszSubKey
= "RecentDocs";
1171 mymru
.lpfnCompare
= SHADD_compare_mru
;
1172 mruhandle
= CreateMRUListA(&mymru
);
1175 ERR("MRU processing failed, handle zero\n");
1176 RegCloseKey(HCUbasekey
);
1179 len
= lstrlenA(doc_name
);
1180 pos
= FindMRUData(mruhandle
, doc_name
, len
, 0);
1182 /* Now get the MRU entry that will be replaced
1183 * and delete the .lnk file for it
1185 if ((bufused
= EnumMRUListA(mruhandle
, (pos
== -1) ? 14 : pos
,
1186 buffer
, 2048)) != -1) {
1188 ptr
+= (lstrlenA(buffer
) + 1);
1189 slen
= *((short int*)ptr
);
1190 ptr
+= 2; /* skip the length area */
1191 if (bufused
>= slen
+ (ptr
-buffer
)) {
1192 /* buffer size looks good */
1193 ptr
+= 12; /* get to string */
1194 len
= bufused
- (ptr
-buffer
); /* get length of buf remaining */
1195 if (ptr
[0] && (lstrlenA(ptr
) <= len
-1)) {
1196 /* appears to be good string */
1197 lstrcpyA(old_lnk_name
, link_dir
);
1198 PathAppendA(old_lnk_name
, ptr
);
1199 if (!DeleteFileA(old_lnk_name
)) {
1200 if ((attr
= GetFileAttributesA(old_lnk_name
)) == INVALID_FILE_ATTRIBUTES
) {
1201 if ((err
= GetLastError()) != ERROR_FILE_NOT_FOUND
) {
1202 ERR("Delete for %s failed, err=%d, attr=%08x\n",
1203 old_lnk_name
, err
, attr
);
1206 TRACE("old .lnk file %s did not exist\n",
1211 ERR("Delete for %s failed, attr=%08x\n",
1212 old_lnk_name
, attr
);
1216 TRACE("deleted old .lnk file %s\n", old_lnk_name
);
1222 /* Create usable .lnk file name for the "Recent" directory
1224 wsprintfA(new_lnk_name
, "%s.lnk", doc_name
);
1225 lstrcpyA(new_lnk_filepath
, link_dir
);
1226 PathAppendA(new_lnk_filepath
, new_lnk_name
);
1228 olderrormode
= SetErrorMode(SEM_FAILCRITICALERRORS
);
1229 while (GetFileAttributesA(new_lnk_filepath
) != INVALID_FILE_ATTRIBUTES
) {
1231 wsprintfA(new_lnk_name
, "%s (%u).lnk", doc_name
, i
);
1232 lstrcpyA(new_lnk_filepath
, link_dir
);
1233 PathAppendA(new_lnk_filepath
, new_lnk_name
);
1235 SetErrorMode(olderrormode
);
1236 TRACE("new shortcut will be %s\n", new_lnk_filepath
);
1238 /* Now add the new MRU entry and data
1240 pos
= SHADD_create_add_mru_data(mruhandle
, doc_name
, new_lnk_name
,
1242 FreeMRUList(mruhandle
);
1243 TRACE("Updated MRU list, new doc is position %d\n", pos
);
1246 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
1248 { /* on input needs:
1249 * doc_name - pure file-spec, no path
1251 * - path and file name of new .lnk file
1252 * uFlags[in] - flags on call to SHAddToRecentDocs
1253 * pv[in] - document path/pidl on call to SHAddToRecentDocs
1255 IShellLinkA
*psl
= NULL
;
1256 IPersistFile
*pPf
= NULL
;
1258 CHAR desc
[MAX_PATH
];
1259 WCHAR widelink
[MAX_PATH
];
1263 hres
= CoCreateInstance( &CLSID_ShellLink
,
1265 CLSCTX_INPROC_SERVER
,
1268 if(SUCCEEDED(hres
)) {
1270 hres
= IShellLinkA_QueryInterface(psl
, &IID_IPersistFile
,
1274 ERR("failed QueryInterface for IPersistFile %08x\n", hres
);
1278 /* Set the document path or pidl */
1279 if (uFlags
== SHARD_PIDL
) {
1280 hres
= IShellLinkA_SetIDList(psl
, pv
);
1282 hres
= IShellLinkA_SetPath(psl
, pv
);
1286 ERR("failed Set{IDList|Path} %08x\n", hres
);
1290 lstrcpyA(desc
, "Shortcut to ");
1291 lstrcatA(desc
, doc_name
);
1292 hres
= IShellLinkA_SetDescription(psl
, desc
);
1295 ERR("failed SetDescription %08x\n", hres
);
1299 MultiByteToWideChar(CP_ACP
, 0, new_lnk_filepath
, -1,
1300 widelink
, MAX_PATH
);
1301 /* create the short cut */
1302 hres
= IPersistFile_Save(pPf
, widelink
, TRUE
);
1305 ERR("failed IPersistFile::Save %08x\n", hres
);
1306 IPersistFile_Release(pPf
);
1307 IShellLinkA_Release(psl
);
1310 hres
= IPersistFile_SaveCompleted(pPf
, widelink
);
1311 IPersistFile_Release(pPf
);
1312 IShellLinkA_Release(psl
);
1313 TRACE("shortcut %s has been created, result=%08x\n",
1314 new_lnk_filepath
, hres
);
1317 ERR("CoCreateInstance failed, hres=%08x\n", hres
);
1325 RegCloseKey(HCUbasekey
);
1330 /*************************************************************************
1331 * SHCreateShellFolderViewEx [SHELL32.174]
1333 * Create a new instance of the default Shell folder view object.
1337 * Failure: error value
1340 * see IShellFolder::CreateViewObject
1344 HRESULT WINAPI
SHCreateShellFolderViewEx(
1345 LPCSFV psvcbi
, /* [in] shelltemplate struct */
1346 IShellView
**ppv
) /* [out] IShellView pointer */
1351 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1352 psvcbi
->pshf
, psvcbi
->pidl
, psvcbi
->pfnCallback
,
1353 psvcbi
->fvm
, psvcbi
->psvOuter
);
1356 hRes
= IShellView_Constructor(psvcbi
->pshf
, &psf
);
1361 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppv
);
1362 IShellView_Release(psf
);
1368 /*************************************************************************
1369 * SHWinHelp [SHELL32.127]
1372 HRESULT WINAPI
SHWinHelp (DWORD v
, DWORD w
, DWORD x
, DWORD z
)
1373 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v
,w
,x
,z
);
1376 /*************************************************************************
1377 * SHRunControlPanel [SHELL32.161]
1380 BOOL WINAPI
SHRunControlPanel (LPCWSTR commandLine
, HWND parent
)
1382 FIXME("(%s, %p): stub\n", debugstr_w(commandLine
), parent
);
1386 static LPUNKNOWN SHELL32_IExplorerInterface
=0;
1387 /*************************************************************************
1388 * SHSetInstanceExplorer [SHELL32.176]
1391 * Sets the interface
1393 VOID WINAPI
SHSetInstanceExplorer (LPUNKNOWN lpUnknown
)
1394 { TRACE("%p\n", lpUnknown
);
1395 SHELL32_IExplorerInterface
= lpUnknown
;
1397 /*************************************************************************
1398 * SHGetInstanceExplorer [SHELL32.@]
1401 * gets the interface pointer of the explorer and a reference
1403 HRESULT WINAPI
SHGetInstanceExplorer (IUnknown
**lpUnknown
)
1404 { TRACE("%p\n", lpUnknown
);
1406 *lpUnknown
= SHELL32_IExplorerInterface
;
1408 if (!SHELL32_IExplorerInterface
)
1411 IUnknown_AddRef(SHELL32_IExplorerInterface
);
1414 /*************************************************************************
1415 * SHFreeUnusedLibraries [SHELL32.123]
1417 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1418 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1422 * exported by ordinal
1425 * CoFreeUnusedLibraries, SHLoadOLE
1427 void WINAPI
SHFreeUnusedLibraries (void)
1430 CoFreeUnusedLibraries();
1432 /*************************************************************************
1433 * DAD_AutoScroll [SHELL32.129]
1436 BOOL WINAPI
DAD_AutoScroll(HWND hwnd
, AUTO_SCROLL_DATA
*samples
, const POINT
* pt
)
1438 FIXME("hwnd = %p %p %p\n",hwnd
,samples
,pt
);
1441 /*************************************************************************
1442 * DAD_DragEnter [SHELL32.130]
1445 BOOL WINAPI
DAD_DragEnter(HWND hwnd
)
1447 FIXME("hwnd = %p\n",hwnd
);
1450 /*************************************************************************
1451 * DAD_DragEnterEx [SHELL32.131]
1454 BOOL WINAPI
DAD_DragEnterEx(HWND hwnd
, POINT p
)
1456 FIXME("hwnd = %p (%d,%d)\n",hwnd
,p
.x
,p
.y
);
1459 /*************************************************************************
1460 * DAD_DragMove [SHELL32.134]
1463 BOOL WINAPI
DAD_DragMove(POINT p
)
1465 FIXME("(%d,%d)\n",p
.x
,p
.y
);
1468 /*************************************************************************
1469 * DAD_DragLeave [SHELL32.132]
1472 BOOL WINAPI
DAD_DragLeave(VOID
)
1477 /*************************************************************************
1478 * DAD_SetDragImage [SHELL32.136]
1483 BOOL WINAPI
DAD_SetDragImage(
1484 HIMAGELIST himlTrack
,
1487 FIXME("%p %p stub\n",himlTrack
, lppt
);
1490 /*************************************************************************
1491 * DAD_ShowDragImage [SHELL32.137]
1496 BOOL WINAPI
DAD_ShowDragImage(BOOL bShow
)
1498 FIXME("0x%08x stub\n",bShow
);
1502 static const WCHAR szwCabLocation
[] = {
1503 'S','o','f','t','w','a','r','e','\\',
1504 'M','i','c','r','o','s','o','f','t','\\',
1505 'W','i','n','d','o','w','s','\\',
1506 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1507 'E','x','p','l','o','r','e','r','\\',
1508 'C','a','b','i','n','e','t','S','t','a','t','e',0
1511 static const WCHAR szwSettings
[] = { 'S','e','t','t','i','n','g','s',0 };
1513 /*************************************************************************
1514 * ReadCabinetState [SHELL32.651] NT 4.0
1517 BOOL WINAPI
ReadCabinetState(CABINETSTATE
*cs
, int length
)
1522 TRACE("%p %d\n", cs
, length
);
1524 if( (cs
== NULL
) || (length
< (int)sizeof(*cs
)) )
1527 r
= RegOpenKeyW( HKEY_CURRENT_USER
, szwCabLocation
, &hkey
);
1528 if( r
== ERROR_SUCCESS
)
1531 r
= RegQueryValueExW( hkey
, szwSettings
,
1532 NULL
, &type
, (LPBYTE
)cs
, (LPDWORD
)&length
);
1533 RegCloseKey( hkey
);
1537 /* if we can't read from the registry, create default values */
1538 if ( (r
!= ERROR_SUCCESS
) || (cs
->cLength
< sizeof(*cs
)) ||
1539 (cs
->cLength
!= length
) )
1541 TRACE("Initializing shell cabinet settings\n");
1542 memset(cs
, 0, sizeof(*cs
));
1543 cs
->cLength
= sizeof(*cs
);
1545 cs
->fFullPathTitle
= FALSE
;
1546 cs
->fSaveLocalView
= TRUE
;
1547 cs
->fNotShell
= FALSE
;
1548 cs
->fSimpleDefault
= TRUE
;
1549 cs
->fDontShowDescBar
= FALSE
;
1550 cs
->fNewWindowMode
= FALSE
;
1551 cs
->fShowCompColor
= FALSE
;
1552 cs
->fDontPrettyNames
= FALSE
;
1553 cs
->fAdminsCreateCommonGroups
= TRUE
;
1554 cs
->fMenuEnumFilter
= 96;
1560 /*************************************************************************
1561 * WriteCabinetState [SHELL32.652] NT 4.0
1564 BOOL WINAPI
WriteCabinetState(CABINETSTATE
*cs
)
1574 r
= RegCreateKeyExW( HKEY_CURRENT_USER
, szwCabLocation
, 0,
1575 NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
1576 if( r
== ERROR_SUCCESS
)
1578 r
= RegSetValueExW( hkey
, szwSettings
, 0,
1579 REG_BINARY
, (LPBYTE
) cs
, cs
->cLength
);
1581 RegCloseKey( hkey
);
1584 return (r
==ERROR_SUCCESS
);
1587 /*************************************************************************
1588 * FileIconInit [SHELL32.660]
1591 BOOL WINAPI
FileIconInit(BOOL bFullInit
)
1593 return SIC_Initialize();
1596 /*************************************************************************
1597 * SetAppStartingCursor [SHELL32.99]
1599 HRESULT WINAPI
SetAppStartingCursor(HWND u
, DWORD v
)
1600 { FIXME("hwnd=%p 0x%04x stub\n",u
,v
);
1604 /*************************************************************************
1605 * SHLoadOLE [SHELL32.151]
1607 * To reduce the memory usage of Windows 95, its shell32 contained an
1608 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1609 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1610 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1611 * would just call the Co* functions.
1613 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1614 * information from the shell32 "mini-COM" to ole32.dll.
1616 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1617 * detailed description.
1619 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1620 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1621 * hack in SHCoCreateInstance)
1623 HRESULT WINAPI
SHLoadOLE(LPARAM lParam
)
1624 { FIXME("0x%08lx stub\n",lParam
);
1627 /*************************************************************************
1628 * DriveType [SHELL32.64]
1631 int WINAPI
DriveType(int DriveType
)
1633 WCHAR root
[] = L
"A:\\";
1634 root
[0] = L
'A' + DriveType
;
1635 return GetDriveTypeW(root
);
1637 /*************************************************************************
1638 * InvalidateDriveType [SHELL32.65]
1639 * Unimplemented in XP SP3
1641 int WINAPI
InvalidateDriveType(int u
)
1643 TRACE("0x%08x stub\n",u
);
1646 /*************************************************************************
1647 * SHAbortInvokeCommand [SHELL32.198]
1650 HRESULT WINAPI
SHAbortInvokeCommand(void)
1654 /*************************************************************************
1655 * SHOutOfMemoryMessageBox [SHELL32.126]
1658 int WINAPI
SHOutOfMemoryMessageBox(
1663 FIXME("%p %s 0x%08x stub\n",hwndOwner
, lpCaption
, uType
);
1666 /*************************************************************************
1667 * SHFlushClipboard [SHELL32.121]
1670 HRESULT WINAPI
SHFlushClipboard(void)
1672 return OleFlushClipboard();
1675 /*************************************************************************
1676 * SHWaitForFileToOpen [SHELL32.97]
1679 BOOL WINAPI
SHWaitForFileToOpen(
1684 FIXME("%p 0x%08x 0x%08x stub\n", pidl
, dwFlags
, dwTimeout
);
1688 /************************************************************************
1689 * RLBuildListOfPaths [SHELL32.146]
1694 DWORD WINAPI
RLBuildListOfPaths (void)
1698 /************************************************************************
1699 * SHValidateUNC [SHELL32.173]
1702 BOOL WINAPI
SHValidateUNC (HWND hwndOwner
, PWSTR pszFile
, UINT fConnect
)
1704 FIXME("(%p, %s, 0x%08x): stub\n", hwndOwner
, debugstr_w(pszFile
), fConnect
);
1708 /************************************************************************
1709 * DoEnvironmentSubstA [SHELL32.@]
1711 * See DoEnvironmentSubstW.
1713 DWORD WINAPI
DoEnvironmentSubstA(LPSTR pszString
, UINT cchString
)
1717 DWORD len
= cchString
;
1719 TRACE("(%s, %d)\n", debugstr_a(pszString
), cchString
);
1720 if (pszString
== NULL
) /* Really return 0? */
1722 if ((dst
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(CHAR
))))
1724 len
= ExpandEnvironmentStringsA(pszString
, dst
, cchString
);
1725 /* len includes the terminating 0 */
1726 if (len
&& len
< cchString
)
1729 memcpy(pszString
, dst
, len
);
1734 HeapFree(GetProcessHeap(), 0, dst
);
1736 return MAKELONG(len
, res
);
1739 /************************************************************************
1740 * DoEnvironmentSubstW [SHELL32.@]
1742 * Replace all %KEYWORD% in the string with the value of the named
1743 * environment variable. If the buffer is too small, the string is not modified.
1746 * pszString [I] '\0' terminated string with %keyword%.
1747 * [O] '\0' terminated string with %keyword% substituted.
1748 * cchString [I] size of str.
1751 * Success: The string in the buffer is updated
1753 * LOWORD: characters used in the buffer, including space for the terminating 0
1754 * Failure: buffer too small. The string is not modified.
1756 * LOWORD: provided size of the buffer in characters
1758 DWORD WINAPI
DoEnvironmentSubstW(LPWSTR pszString
, UINT cchString
)
1762 DWORD len
= cchString
;
1764 TRACE("(%s, %d)\n", debugstr_w(pszString
), cchString
);
1766 if ((cchString
< MAXLONG
) && (dst
= HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(WCHAR
))))
1768 len
= ExpandEnvironmentStringsW(pszString
, dst
, cchString
);
1769 /* len includes the terminating 0 */
1770 if (len
&& len
<= cchString
)
1773 memcpy(pszString
, dst
, len
* sizeof(WCHAR
));
1778 HeapFree(GetProcessHeap(), 0, dst
);
1780 return MAKELONG(len
, res
);
1783 /************************************************************************
1784 * DoEnvironmentSubst [SHELL32.53]
1786 * See DoEnvironmentSubstA.
1788 DWORD WINAPI
DoEnvironmentSubstAW(LPVOID x
, UINT y
)
1790 if (SHELL_OsIsUnicode())
1791 return DoEnvironmentSubstW(x
, y
);
1792 return DoEnvironmentSubstA(x
, y
);
1795 /*************************************************************************
1796 * GUIDFromStringA [SHELL32.703]
1798 BOOL WINAPI
GUIDFromStringA(LPCSTR str
, LPGUID guid
)
1800 TRACE("GUIDFromStringA() stub\n");
1804 /*************************************************************************
1805 * GUIDFromStringW [SHELL32.704]
1807 BOOL WINAPI
GUIDFromStringW(LPCWSTR str
, LPGUID guid
)
1809 UNICODE_STRING guid_str
;
1811 RtlInitUnicodeString(&guid_str
, str
);
1812 return !RtlGUIDFromString(&guid_str
, guid
);
1815 /*************************************************************************
1816 * PathIsTemporaryA [SHELL32.713]
1818 BOOL WINAPI
PathIsTemporaryA(LPSTR Str
)
1820 FIXME("(%s)stub\n", debugstr_a(Str
));
1824 /*************************************************************************
1825 * PathIsTemporaryW [SHELL32.714]
1827 BOOL WINAPI
PathIsTemporaryW(LPWSTR Str
)
1829 FIXME("(%s)stub\n", debugstr_w(Str
));
1833 typedef struct _PSXA
1837 IShellPropSheetExt
*pspsx
[1];
1840 typedef struct _PSXA_CALL
1842 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith
;
1847 } PSXA_CALL
, *PPSXA_CALL
;
1849 static BOOL CALLBACK
PsxaCall(HPROPSHEETPAGE hpage
, LPARAM lParam
)
1851 PPSXA_CALL Call
= (PPSXA_CALL
)lParam
;
1855 if ((Call
->bMultiple
|| !Call
->bCalled
) &&
1856 Call
->lpfnAddReplaceWith(hpage
, Call
->lParam
))
1858 Call
->bCalled
= TRUE
;
1867 /*************************************************************************
1868 * SHAddFromPropSheetExtArray [SHELL32.167]
1870 UINT WINAPI
SHAddFromPropSheetExtArray(HPSXA hpsxa
, LPFNADDPROPSHEETPAGE lpfnAddPage
, LPARAM lParam
)
1874 PPSXA psxa
= (PPSXA
)hpsxa
;
1876 TRACE("(%p,%p,%08lx)\n", hpsxa
, lpfnAddPage
, lParam
);
1880 ZeroMemory(&Call
, sizeof(Call
));
1881 Call
.lpfnAddReplaceWith
= lpfnAddPage
;
1882 Call
.lParam
= lParam
;
1883 Call
.bMultiple
= TRUE
;
1885 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1886 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1888 psxa
->pspsx
[i
]->lpVtbl
->AddPages(psxa
->pspsx
[i
], PsxaCall
, (LPARAM
)&Call
);
1891 return Call
.uiCount
;
1897 /*************************************************************************
1898 * SHCreatePropSheetExtArray [SHELL32.168]
1900 HPSXA WINAPI
SHCreatePropSheetExtArray(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
)
1902 return SHCreatePropSheetExtArrayEx(hKey
, pszSubKey
, max_iface
, NULL
);
1905 /*************************************************************************
1906 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1908 HPSXA WINAPI
SHCreatePropSheetExtArrayEx(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
, LPDATAOBJECT pDataObj
)
1910 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};
1911 WCHAR szHandler
[64];
1913 WCHAR szClsidHandler
[39];
1918 IShellExtInit
*psxi
;
1919 IShellPropSheetExt
*pspsx
;
1920 HKEY hkBase
, hkPropSheetHandlers
;
1923 TRACE("(%p,%s,%u)\n", hKey
, debugstr_w(pszSubKey
), max_iface
);
1928 /* Open the registry key */
1929 lRet
= RegOpenKeyW(hKey
, pszSubKey
, &hkBase
);
1930 if (lRet
!= ERROR_SUCCESS
)
1933 lRet
= RegOpenKeyExW(hkBase
, szPropSheetSubKey
, 0, KEY_ENUMERATE_SUB_KEYS
, &hkPropSheetHandlers
);
1934 RegCloseKey(hkBase
);
1935 if (lRet
== ERROR_SUCCESS
)
1937 /* Create and initialize the Property Sheet Extensions Array */
1938 psxa
= LocalAlloc(LMEM_FIXED
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1941 ZeroMemory(psxa
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1942 psxa
->uiAllocated
= max_iface
;
1944 /* Enumerate all subkeys and attempt to load the shell extensions */
1948 dwHandlerLen
= sizeof(szHandler
) / sizeof(szHandler
[0]);
1949 lRet
= RegEnumKeyExW(hkPropSheetHandlers
, dwIndex
++, szHandler
, &dwHandlerLen
, NULL
, NULL
, NULL
, NULL
);
1950 if (lRet
!= ERROR_SUCCESS
)
1952 if (lRet
== ERROR_MORE_DATA
)
1955 if (lRet
== ERROR_NO_MORE_ITEMS
)
1956 lRet
= ERROR_SUCCESS
;
1960 /* The CLSID is stored either in the key itself or in its default value. */
1961 if (FAILED(lRet
= SHCLSIDFromStringW(szHandler
, &clsid
)))
1963 dwClsidSize
= sizeof(szClsidHandler
);
1964 if (SHGetValueW(hkPropSheetHandlers
, szHandler
, NULL
, NULL
, szClsidHandler
, &dwClsidSize
) == ERROR_SUCCESS
)
1966 /* Force a NULL-termination and convert the string */
1967 szClsidHandler
[(sizeof(szClsidHandler
) / sizeof(szClsidHandler
[0])) - 1] = 0;
1968 lRet
= SHCLSIDFromStringW(szClsidHandler
, &clsid
);
1972 if (SUCCEEDED(lRet
))
1974 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1975 Only if both interfaces are supported it's a real shell extension.
1976 Then call IShellExtInit's Initialize method. */
1977 if (SUCCEEDED(CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt
, (LPVOID
*)&pspsx
)))
1979 if (SUCCEEDED(pspsx
->lpVtbl
->QueryInterface(pspsx
, &IID_IShellExtInit
, (PVOID
*)&psxi
)))
1981 if (SUCCEEDED(psxi
->lpVtbl
->Initialize(psxi
, NULL
, pDataObj
, hKey
)))
1983 /* Add the IShellPropSheetExt instance to the array */
1984 psxa
->pspsx
[psxa
->uiCount
++] = pspsx
;
1988 psxi
->lpVtbl
->Release(psxi
);
1989 pspsx
->lpVtbl
->Release(pspsx
);
1993 pspsx
->lpVtbl
->Release(pspsx
);
1997 } while (psxa
->uiCount
!= psxa
->uiAllocated
);
2000 lRet
= ERROR_NOT_ENOUGH_MEMORY
;
2002 RegCloseKey(hkPropSheetHandlers
);
2005 if (lRet
!= ERROR_SUCCESS
&& psxa
)
2007 SHDestroyPropSheetExtArray((HPSXA
)psxa
);
2014 /*************************************************************************
2015 * SHReplaceFromPropSheetExtArray [SHELL32.170]
2017 UINT WINAPI
SHReplaceFromPropSheetExtArray(HPSXA hpsxa
, UINT uPageID
, LPFNADDPROPSHEETPAGE lpfnReplaceWith
, LPARAM lParam
)
2021 PPSXA psxa
= (PPSXA
)hpsxa
;
2023 TRACE("(%p,%u,%p,%08lx)\n", hpsxa
, uPageID
, lpfnReplaceWith
, lParam
);
2027 ZeroMemory(&Call
, sizeof(Call
));
2028 Call
.lpfnAddReplaceWith
= lpfnReplaceWith
;
2029 Call
.lParam
= lParam
;
2031 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
2032 Each shell extension is only allowed to call the callback once during the callback. */
2033 for (i
= 0; i
!= psxa
->uiCount
; i
++)
2035 Call
.bCalled
= FALSE
;
2036 psxa
->pspsx
[i
]->lpVtbl
->ReplacePage(psxa
->pspsx
[i
], uPageID
, PsxaCall
, (LPARAM
)&Call
);
2039 return Call
.uiCount
;
2045 /*************************************************************************
2046 * SHDestroyPropSheetExtArray [SHELL32.169]
2048 void WINAPI
SHDestroyPropSheetExtArray(HPSXA hpsxa
)
2051 PPSXA psxa
= (PPSXA
)hpsxa
;
2053 TRACE("(%p)\n", hpsxa
);
2057 for (i
= 0; i
!= psxa
->uiCount
; i
++)
2059 psxa
->pspsx
[i
]->lpVtbl
->Release(psxa
->pspsx
[i
]);
2066 /*************************************************************************
2067 * CIDLData_CreateFromIDArray [SHELL32.83]
2069 * Create IDataObject from PIDLs??
2071 HRESULT WINAPI
CIDLData_CreateFromIDArray(
2072 PCIDLIST_ABSOLUTE pidlFolder
,
2074 PCUIDLIST_RELATIVE_ARRAY lppidlFiles
,
2075 LPDATAOBJECT
*ppdataObject
)
2078 HWND hwnd
= 0; /*FIXME: who should be hwnd of owner? set to desktop */
2081 TRACE("(%p, %d, %p, %p)\n", pidlFolder
, cpidlFiles
, lppidlFiles
, ppdataObject
);
2085 for (i
=0; i
<cpidlFiles
; i
++) pdump (lppidlFiles
[i
]);
2087 hResult
= IDataObject_Constructor(hwnd
, pidlFolder
, lppidlFiles
, cpidlFiles
, FALSE
, ppdataObject
);
2091 /*************************************************************************
2092 * SHCreateStdEnumFmtEtc [SHELL32.74]
2097 HRESULT WINAPI
SHCreateStdEnumFmtEtc(
2099 const FORMATETC
*lpFormats
,
2100 LPENUMFORMATETC
*ppenumFormatetc
)
2102 IEnumFORMATETC
*pef
;
2104 TRACE("cf=%d fe=%p pef=%p\n", cFormats
, lpFormats
, ppenumFormatetc
);
2106 hRes
= IEnumFORMATETC_Constructor(cFormats
, lpFormats
, &pef
);
2110 IEnumFORMATETC_AddRef(pef
);
2111 hRes
= IEnumFORMATETC_QueryInterface(pef
, &IID_IEnumFORMATETC
, (LPVOID
*)ppenumFormatetc
);
2112 IEnumFORMATETC_Release(pef
);
2117 /*************************************************************************
2118 * SHFindFiles (SHELL32.90)
2120 BOOL WINAPI
SHFindFiles( PCIDLIST_ABSOLUTE pidlFolder
, PCIDLIST_ABSOLUTE pidlSaveFile
)
2122 FIXME("params ignored: %p %p\n", pidlFolder
, pidlSaveFile
);
2123 if (SHRestricted(REST_NOFIND
))
2127 /* Open the search results folder */
2128 /* FIXME: CSearchBar should be opened as well */
2129 return ShellExecuteW(NULL
, NULL
, L
"explorer.exe", L
"::{E17D4FC0-5564-11D1-83F2-00A0C90DC849}", NULL
, SW_SHOWNORMAL
) > (HINSTANCE
)32;
2132 /*************************************************************************
2133 * SHUpdateImageW (SHELL32.192)
2135 * Notifies the shell that an icon in the system image list has been changed.
2138 * pszHashItem [I] Path to file that contains the icon.
2139 * iIndex [I] Zero-based index of the icon in the file.
2140 * uFlags [I] Flags determining the icon attributes. See notes.
2141 * iImageIndex [I] Index of the icon in the system image list.
2147 * uFlags can be one or more of the following flags:
2148 * GIL_NOTFILENAME - pszHashItem is not a file name.
2149 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
2151 void WINAPI
SHUpdateImageW(LPCWSTR pszHashItem
, int iIndex
, UINT uFlags
, int iImageIndex
)
2153 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
2156 /*************************************************************************
2157 * SHUpdateImageA (SHELL32.191)
2159 * See SHUpdateImageW.
2161 VOID WINAPI
SHUpdateImageA(LPCSTR pszHashItem
, INT iIndex
, UINT uFlags
, INT iImageIndex
)
2163 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
2166 INT WINAPI
SHHandleUpdateImage(PCIDLIST_ABSOLUTE pidlExtra
)
2168 FIXME("%p - stub\n", pidlExtra
);
2173 BOOL WINAPI
SHObjectProperties(HWND hwnd
, DWORD dwType
, LPCWSTR szObject
, LPCWSTR szPage
)
2175 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd
, dwType
, debugstr_w(szObject
), debugstr_w(szPage
));
2180 BOOL WINAPI
SHGetNewLinkInfoA(LPCSTR pszLinkTo
, LPCSTR pszDir
, LPSTR pszName
, BOOL
*pfMustCopy
,
2183 WCHAR wszLinkTo
[MAX_PATH
];
2184 WCHAR wszDir
[MAX_PATH
];
2185 WCHAR wszName
[MAX_PATH
];
2188 MultiByteToWideChar(CP_ACP
, 0, pszLinkTo
, -1, wszLinkTo
, MAX_PATH
);
2189 MultiByteToWideChar(CP_ACP
, 0, pszDir
, -1, wszDir
, MAX_PATH
);
2191 res
= SHGetNewLinkInfoW(wszLinkTo
, wszDir
, wszName
, pfMustCopy
, uFlags
);
2194 WideCharToMultiByte(CP_ACP
, 0, wszName
, -1, pszName
, MAX_PATH
, NULL
, NULL
);
2199 BOOL WINAPI
SHGetNewLinkInfoW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
, BOOL
*pfMustCopy
,
2202 const WCHAR
*basename
;
2203 WCHAR
*dst_basename
;
2205 static const WCHAR lnkformat
[] = {'%','s','.','l','n','k',0};
2206 static const WCHAR lnkformatnum
[] = {'%','s',' ','(','%','d',')','.','l','n','k',0};
2208 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo
), debugstr_w(pszDir
),
2209 pszName
, pfMustCopy
, uFlags
);
2211 *pfMustCopy
= FALSE
;
2213 if (uFlags
& SHGNLI_PIDL
)
2215 FIXME("SHGNLI_PIDL flag unsupported\n");
2220 FIXME("ignoring flags: 0x%08x\n", uFlags
);
2222 /* FIXME: should test if the file is a shortcut or DOS program */
2223 if (GetFileAttributesW(pszLinkTo
) == INVALID_FILE_ATTRIBUTES
)
2226 basename
= strrchrW(pszLinkTo
, '\\');
2228 basename
= basename
+1;
2230 basename
= pszLinkTo
;
2232 lstrcpynW(pszName
, pszDir
, MAX_PATH
);
2233 if (!PathAddBackslashW(pszName
))
2236 dst_basename
= pszName
+ strlenW(pszName
);
2238 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformat
, basename
);
2240 while (GetFileAttributesW(pszName
) != INVALID_FILE_ATTRIBUTES
)
2242 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformatnum
, basename
, i
);
2249 HRESULT WINAPI
SHStartNetConnectionDialog(HWND hwnd
, LPCSTR pszRemoteName
, DWORD dwType
)
2251 FIXME("%p, %s, 0x%08x - stub\n", hwnd
, debugstr_a(pszRemoteName
), dwType
);
2255 /*************************************************************************
2256 * SHSetLocalizedName (SHELL32.@)
2258 HRESULT WINAPI
SHSetLocalizedName(LPCWSTR pszPath
, LPCWSTR pszResModule
, int idsRes
)
2260 FIXME("%p, %s, %d - stub\n", pszPath
, debugstr_w(pszResModule
), idsRes
);
2265 /*************************************************************************
2266 * LinkWindow_RegisterClass (SHELL32.258)
2268 BOOL WINAPI
LinkWindow_RegisterClass(void)
2274 /*************************************************************************
2275 * LinkWindow_UnregisterClass (SHELL32.259)
2277 BOOL WINAPI
LinkWindow_UnregisterClass(DWORD dwUnused
)
2283 /*************************************************************************
2284 * SHFlushSFCache (SHELL32.526)
2286 * Notifies the shell that a user-specified special folder location has changed.
2289 * In Wine, the shell folder registry values are not cached, so this function
2292 void WINAPI
SHFlushSFCache(void)
2296 /*************************************************************************
2297 * SHGetImageList (SHELL32.727)
2299 * Returns a copy of a shell image list.
2302 * Windows XP features 4 sizes of image list, and Vista 5. Wine currently
2303 * only supports the traditional small and large image lists, so requests
2304 * for the others will currently fail.
2306 HRESULT WINAPI
SHGetImageList(int iImageList
, REFIID riid
, void **ppv
)
2308 HIMAGELIST hLarge
, hSmall
;
2310 HRESULT ret
= E_FAIL
;
2312 /* Wine currently only maintains large and small image lists */
2313 if ((iImageList
!= SHIL_LARGE
) && (iImageList
!= SHIL_SMALL
) && (iImageList
!= SHIL_SYSSMALL
))
2315 FIXME("Unsupported image list %i requested\n", iImageList
);
2319 Shell_GetImageLists(&hLarge
, &hSmall
);
2321 hNew
= ImageList_Duplicate(iImageList
== SHIL_LARGE
? hLarge
: hSmall
);
2323 /* Get the interface for the new image list */
2326 ret
= HIMAGELIST_QueryInterface(hNew
, riid
, ppv
);
2327 ImageList_Destroy(hNew
);
2330 /* Duplicating the imagelist causes the start menu items not to draw on
2331 * the first show. Was the Duplicate necessary for some reason? I believe
2332 * Windows returns the raw pointer here. */
2333 hNew
= (iImageList
== SHIL_LARGE
? hLarge
: hSmall
);
2334 ret
= IImageList2_QueryInterface((IImageList2
*) hNew
, riid
, ppv
);
2342 /*************************************************************************
2343 * SHCreateShellFolderView [SHELL32.256]
2345 * Create a new instance of the default Shell folder view object.
2349 * Failure: error value
2352 * see IShellFolder::CreateViewObject
2354 HRESULT WINAPI
SHCreateShellFolderView(const SFV_CREATE
*pcsfv
,
2361 if (!pcsfv
|| pcsfv
->cbSize
!= sizeof(*pcsfv
))
2362 return E_INVALIDARG
;
2364 TRACE("sf=%p outer=%p callback=%p\n",
2365 pcsfv
->pshf
, pcsfv
->psvOuter
, pcsfv
->psfvcb
);
2367 hRes
= IShellView_Constructor(pcsfv
->pshf
, &psf
);
2371 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppsv
);
2372 IShellView_Release(psf
);
2379 /*************************************************************************
2380 * SHTestTokenMembership [SHELL32.245]
2382 * Checks whether a given token is a mamber of a local group with the
2388 SHTestTokenMembership(HANDLE TokenHandle
, ULONG ulRID
)
2390 SID_IDENTIFIER_AUTHORITY ntAuth
= {SECURITY_NT_AUTHORITY
};
2391 DWORD nSubAuthority0
, nSubAuthority1
;
2392 DWORD nSubAuthorityCount
;
2394 BOOL IsMember
= FALSE
;
2396 if ((ulRID
== SECURITY_SERVICE_RID
) || ulRID
== SECURITY_LOCAL_SYSTEM_RID
)
2398 nSubAuthority0
= ulRID
;
2400 nSubAuthorityCount
= 1;
2404 nSubAuthority0
= SECURITY_BUILTIN_DOMAIN_RID
;
2405 nSubAuthority1
= ulRID
;
2406 nSubAuthorityCount
= 2;
2409 if (!AllocateAndInitializeSid(&ntAuth
,
2419 if (!CheckTokenMembership(TokenHandle
, SidToCheck
, &IsMember
))
2424 FreeSid(SidToCheck
);
2428 /*************************************************************************
2429 * IsUserAnAdmin [SHELL32.680] NT 4.0
2431 * Checks whether the current user is a member of the Administrators group.
2440 BOOL WINAPI
IsUserAnAdmin(VOID
)
2442 return SHTestTokenMembership(NULL
, DOMAIN_ALIAS_RID_ADMINS
);
2445 /*************************************************************************
2446 * SHLimitInputEdit(SHELL32.@)
2449 /* TODO: Show baloon popup window with TTS_BALLOON */
2451 typedef struct UxSubclassInfo
2455 LPWSTR pwszValidChars
;
2456 LPWSTR pwszInvalidChars
;
2460 UxSubclassInfo_Destroy(UxSubclassInfo
*pInfo
)
2465 RemovePropW(pInfo
->hwnd
, L
"UxSubclassInfo");
2467 CoTaskMemFree(pInfo
->pwszValidChars
);
2468 CoTaskMemFree(pInfo
->pwszInvalidChars
);
2470 SetWindowLongPtrW(pInfo
->hwnd
, GWLP_WNDPROC
, (LONG_PTR
)pInfo
->fnWndProc
);
2472 HeapFree(GetProcessHeap(), 0, pInfo
);
2476 DoSanitizeText(LPWSTR pszSanitized
, LPCWSTR pszInvalidChars
, LPCWSTR pszValidChars
)
2479 BOOL bFound
= FALSE
;
2481 for (pch1
= pch2
= pszSanitized
; *pch1
; ++pch1
)
2483 if (pszInvalidChars
)
2485 if (wcschr(pszInvalidChars
, *pch1
) != NULL
)
2491 else if (pszValidChars
)
2493 if (wcschr(pszValidChars
, *pch1
) == NULL
)
2509 DoSanitizeClipboard(HWND hwnd
, UxSubclassInfo
*pInfo
)
2512 LPWSTR pszText
, pszSanitized
;
2515 if (GetWindowLongPtrW(hwnd
, GWL_STYLE
) & ES_READONLY
)
2517 if (!OpenClipboard(hwnd
))
2520 hData
= GetClipboardData(CF_UNICODETEXT
);
2521 pszText
= GlobalLock(hData
);
2527 SHStrDupW(pszText
, &pszSanitized
);
2528 GlobalUnlock(hData
);
2531 DoSanitizeText(pszSanitized
, pInfo
->pwszInvalidChars
, pInfo
->pwszValidChars
))
2533 MessageBeep(0xFFFFFFFF);
2535 /* Update clipboard text */
2536 cbData
= (lstrlenW(pszSanitized
) + 1) * sizeof(WCHAR
);
2537 hData
= GlobalAlloc(GMEM_MOVEABLE
| GMEM_SHARE
, cbData
);
2538 pszText
= GlobalLock(hData
);
2541 CopyMemory(pszText
, pszSanitized
, cbData
);
2542 GlobalUnlock(hData
);
2544 SetClipboardData(CF_UNICODETEXT
, hData
);
2548 CoTaskMemFree(pszSanitized
);
2552 static LRESULT CALLBACK
2553 LimitEditWindowProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2557 UxSubclassInfo
*pInfo
= GetPropW(hwnd
, L
"UxSubclassInfo");
2559 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
2561 fnWndProc
= pInfo
->fnWndProc
;
2566 if (GetKeyState(VK_SHIFT
) < 0 && wParam
== VK_INSERT
)
2567 DoSanitizeClipboard(hwnd
, pInfo
);
2568 else if (GetKeyState(VK_CONTROL
) < 0 && wParam
== L
'V')
2569 DoSanitizeClipboard(hwnd
, pInfo
);
2571 return CallWindowProcW(fnWndProc
, hwnd
, uMsg
, wParam
, lParam
);
2574 DoSanitizeClipboard(hwnd
, pInfo
);
2575 return CallWindowProcW(fnWndProc
, hwnd
, uMsg
, wParam
, lParam
);
2578 if (GetKeyState(VK_CONTROL
) < 0 && wParam
== L
'V')
2581 if (pInfo
->pwszInvalidChars
)
2583 if (wcschr(pInfo
->pwszInvalidChars
, (WCHAR
)wParam
) != NULL
)
2585 MessageBeep(0xFFFFFFFF);
2589 else if (pInfo
->pwszValidChars
)
2591 if (wcschr(pInfo
->pwszValidChars
, (WCHAR
)wParam
) == NULL
)
2593 MessageBeep(0xFFFFFFFF);
2597 return CallWindowProcW(fnWndProc
, hwnd
, uMsg
, wParam
, lParam
);
2600 if (wParam
== UNICODE_NOCHAR
)
2606 wch
= (WCHAR
)wParam
;
2607 if (GetKeyState(VK_CONTROL
) < 0 && wch
== L
'V')
2610 if (!IsWindowUnicode(hwnd
) && HIBYTE(wch
) != 0)
2612 CHAR data
[] = {HIBYTE(wch
), LOBYTE(wch
)};
2613 MultiByteToWideChar(CP_ACP
, 0, data
, 2, &wch
, 1);
2616 if (pInfo
->pwszInvalidChars
)
2618 if (wcschr(pInfo
->pwszInvalidChars
, wch
) != NULL
)
2620 MessageBeep(0xFFFFFFFF);
2624 else if (pInfo
->pwszValidChars
)
2626 if (wcschr(pInfo
->pwszValidChars
, wch
) == NULL
)
2628 MessageBeep(0xFFFFFFFF);
2632 return CallWindowProcW(fnWndProc
, hwnd
, uMsg
, wParam
, lParam
);
2635 UxSubclassInfo_Destroy(pInfo
);
2636 return CallWindowProcW(fnWndProc
, hwnd
, uMsg
, wParam
, lParam
);
2639 return CallWindowProcW(fnWndProc
, hwnd
, uMsg
, wParam
, lParam
);
2645 static UxSubclassInfo
*
2646 UxSubclassInfo_Create(HWND hwnd
, LPWSTR valid
, LPWSTR invalid
)
2648 UxSubclassInfo
*pInfo
;
2649 pInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(UxSubclassInfo
));
2652 ERR("HeapAlloc failed.\n");
2653 CoTaskMemFree(valid
);
2654 CoTaskMemFree(invalid
);
2658 pInfo
->fnWndProc
= (WNDPROC
)SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)LimitEditWindowProc
);
2659 if (!pInfo
->fnWndProc
)
2661 ERR("SetWindowLongPtrW failed\n");
2662 CoTaskMemFree(valid
);
2663 CoTaskMemFree(invalid
);
2664 HeapFree(GetProcessHeap(), 0, pInfo
);
2669 pInfo
->pwszValidChars
= valid
;
2670 pInfo
->pwszInvalidChars
= invalid
;
2671 if (!SetPropW(hwnd
, L
"UxSubclassInfo", pInfo
))
2673 UxSubclassInfo_Destroy(pInfo
);
2680 SHLimitInputEdit(HWND hWnd
, IShellFolder
*psf
)
2682 IItemNameLimits
*pLimits
;
2684 LPWSTR pwszValidChars
, pwszInvalidChars
;
2685 UxSubclassInfo
*pInfo
;
2687 pInfo
= GetPropW(hWnd
, L
"UxSubclassInfo");
2690 UxSubclassInfo_Destroy(pInfo
);
2694 hr
= psf
->lpVtbl
->QueryInterface(psf
, &IID_IItemNameLimits
, (LPVOID
*)&pLimits
);
2697 ERR("hr: %x\n", hr
);
2701 pwszValidChars
= pwszInvalidChars
= NULL
;
2702 hr
= pLimits
->lpVtbl
->GetValidCharacters(pLimits
, &pwszValidChars
, &pwszInvalidChars
);
2705 ERR("hr: %x\n", hr
);
2706 pLimits
->lpVtbl
->Release(pLimits
);
2710 pInfo
= UxSubclassInfo_Create(hWnd
, pwszValidChars
, pwszInvalidChars
);
2714 pLimits
->lpVtbl
->Release(pLimits
);