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
34 #include "wine/debug.h"
44 #include "shell32_main.h"
45 #include "undocshell.h"
49 #include "commoncontrols.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
52 WINE_DECLARE_DEBUG_CHANNEL(pidl
);
54 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
55 /* !!! it is in both here and comctl32undoc.c !!! */
56 typedef struct tagCREATEMRULIST
58 DWORD cbSize
; /* size of struct */
59 DWORD nMaxItems
; /* max no. of items in list */
60 DWORD dwFlags
; /* see below */
61 HKEY hKey
; /* root reg. key under which list is saved */
62 LPCSTR lpszSubKey
; /* reg. subkey */
63 PROC lpfnCompare
; /* item compare proc */
64 } CREATEMRULISTA
, *LPCREATEMRULISTA
;
67 #define MRUF_STRING_LIST 0 /* list will contain strings */
68 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
69 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
71 extern HANDLE WINAPI
CreateMRUListA(LPCREATEMRULISTA lpcml
);
72 extern DWORD WINAPI
FreeMRUList(HANDLE hMRUList
);
73 extern INT WINAPI
AddMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
74 extern INT WINAPI
FindMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
75 extern INT WINAPI
EnumMRUListA(HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
78 /* Get a function pointer from a DLL handle */
79 #define GET_FUNC(func, module, name, fail) \
82 if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
83 func = (void*)GetProcAddress(SHELL32_h##module, name); \
84 if (!func) return fail; \
88 /* Function pointers for GET_FUNC macro */
89 static HMODULE SHELL32_hshlwapi
=NULL
;
90 static HANDLE (WINAPI
*pSHAllocShared
)(LPCVOID
,DWORD
,DWORD
);
91 static LPVOID (WINAPI
*pSHLockShared
)(HANDLE
,DWORD
);
92 static BOOL (WINAPI
*pSHUnlockShared
)(LPVOID
);
93 static BOOL (WINAPI
*pSHFreeShared
)(HANDLE
,DWORD
);
96 /*************************************************************************
97 * ParseFieldA [internal]
99 * copies a field from a ',' delimited string
101 * first field is nField = 1
103 DWORD WINAPI
ParseFieldA(
109 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src
),nField
,dst
,len
);
111 if (!src
|| !src
[0] || !dst
|| !len
)
114 /* skip n fields delimited by ',' */
117 if (*src
=='\0') return FALSE
;
118 if (*(src
++)==',') nField
--;
121 /* copy part till the next ',' to dst */
122 while ( *src
!='\0' && *src
!=',' && (len
--)>0 ) *(dst
++)=*(src
++);
124 /* finalize the string */
130 /*************************************************************************
131 * ParseFieldW [internal]
133 * copies a field from a ',' delimited string
135 * first field is nField = 1
137 DWORD WINAPI
ParseFieldW(LPCWSTR src
, DWORD nField
, LPWSTR dst
, DWORD len
)
139 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src
), nField
, dst
, len
);
141 if (!src
|| !src
[0] || !dst
|| !len
)
144 /* skip n fields delimited by ',' */
147 if (*src
== 0x0) return FALSE
;
148 if (*src
++ == ',') nField
--;
151 /* copy part till the next ',' to dst */
152 while ( *src
!= 0x0 && *src
!= ',' && (len
--)>0 ) *(dst
++) = *(src
++);
154 /* finalize the string */
160 /*************************************************************************
161 * ParseField [SHELL32.58]
163 DWORD WINAPI
ParseFieldAW(LPCVOID src
, DWORD nField
, LPVOID dst
, DWORD len
)
165 if (SHELL_OsIsUnicode())
166 return ParseFieldW(src
, nField
, dst
, len
);
167 return ParseFieldA(src
, nField
, dst
, len
);
170 /*************************************************************************
171 * GetFileNameFromBrowseA [internal]
173 static BOOL
GetFileNameFromBrowseA(
177 LPCSTR lpstrInitialDir
,
183 BOOL (WINAPI
*pGetOpenFileNameA
)(LPOPENFILENAMEA
);
187 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
188 hwndOwner
, lpstrFile
, nMaxFile
, lpstrInitialDir
, lpstrDefExt
,
189 lpstrFilter
, lpstrTitle
);
191 hmodule
= LoadLibraryA("comdlg32.dll");
192 if(!hmodule
) return FALSE
;
193 pGetOpenFileNameA
= (void *)GetProcAddress(hmodule
, "GetOpenFileNameA");
194 if(!pGetOpenFileNameA
)
196 FreeLibrary(hmodule
);
200 memset(&ofn
, 0, sizeof(ofn
));
202 ofn
.lStructSize
= sizeof(ofn
);
203 ofn
.hwndOwner
= hwndOwner
;
204 ofn
.lpstrFilter
= lpstrFilter
;
205 ofn
.lpstrFile
= lpstrFile
;
206 ofn
.nMaxFile
= nMaxFile
;
207 ofn
.lpstrInitialDir
= lpstrInitialDir
;
208 ofn
.lpstrTitle
= lpstrTitle
;
209 ofn
.lpstrDefExt
= lpstrDefExt
;
210 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
211 ret
= pGetOpenFileNameA(&ofn
);
213 FreeLibrary(hmodule
);
217 /*************************************************************************
218 * GetFileNameFromBrowseW [internal]
220 static BOOL
GetFileNameFromBrowseW(
224 LPCWSTR lpstrInitialDir
,
230 BOOL (WINAPI
*pGetOpenFileNameW
)(LPOPENFILENAMEW
);
234 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
235 hwndOwner
, debugstr_w(lpstrFile
), nMaxFile
, debugstr_w(lpstrInitialDir
), debugstr_w(lpstrDefExt
),
236 debugstr_w(lpstrFilter
), debugstr_w(lpstrTitle
));
238 hmodule
= LoadLibraryA("comdlg32.dll");
239 if(!hmodule
) return FALSE
;
240 pGetOpenFileNameW
= (void *)GetProcAddress(hmodule
, "GetOpenFileNameW");
241 if(!pGetOpenFileNameW
)
243 FreeLibrary(hmodule
);
247 memset(&ofn
, 0, sizeof(ofn
));
249 ofn
.lStructSize
= sizeof(ofn
);
250 ofn
.hwndOwner
= hwndOwner
;
251 ofn
.lpstrFilter
= lpstrFilter
;
252 ofn
.lpstrFile
= lpstrFile
;
253 ofn
.nMaxFile
= nMaxFile
;
254 ofn
.lpstrInitialDir
= lpstrInitialDir
;
255 ofn
.lpstrTitle
= lpstrTitle
;
256 ofn
.lpstrDefExt
= lpstrDefExt
;
257 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
258 ret
= pGetOpenFileNameW(&ofn
);
260 FreeLibrary(hmodule
);
264 /*************************************************************************
265 * GetFileNameFromBrowse [SHELL32.63]
268 BOOL WINAPI
GetFileNameFromBrowseAW(
272 LPCVOID lpstrInitialDir
,
277 if (SHELL_OsIsUnicode())
278 return GetFileNameFromBrowseW(hwndOwner
, lpstrFile
, nMaxFile
, lpstrInitialDir
, lpstrDefExt
, lpstrFilter
, lpstrTitle
);
280 return GetFileNameFromBrowseA(hwndOwner
, lpstrFile
, nMaxFile
, lpstrInitialDir
, lpstrDefExt
, lpstrFilter
, lpstrTitle
);
283 /*************************************************************************
284 * SHGetSetSettings [SHELL32.68]
286 VOID WINAPI
SHGetSetSettings(LPSHELLSTATE lpss
, DWORD dwMask
, BOOL bSet
)
290 FIXME("%p 0x%08x TRUE\n", lpss
, dwMask
);
294 SHGetSettings((LPSHELLFLAGSTATE
)lpss
,dwMask
);
298 /*************************************************************************
299 * SHGetSettings [SHELL32.@]
302 * the registry path are for win98 (tested)
303 * and possibly are the same in nt40
306 VOID WINAPI
SHGetSettings(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
)
310 DWORD dwDataSize
= sizeof (DWORD
);
312 TRACE("(%p 0x%08x)\n",lpsfs
,dwMask
);
314 if (RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
315 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0))
318 if ( (SSF_SHOWEXTENSIONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideFileExt", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
319 lpsfs
->fShowExtensions
= ((dwData
== 0) ? 0 : 1);
321 if ( (SSF_SHOWINFOTIP
& dwMask
) && !RegQueryValueExA(hKey
, "ShowInfoTip", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
322 lpsfs
->fShowInfoTip
= ((dwData
== 0) ? 0 : 1);
324 if ( (SSF_DONTPRETTYPATH
& dwMask
) && !RegQueryValueExA(hKey
, "DontPrettyPath", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
325 lpsfs
->fDontPrettyPath
= ((dwData
== 0) ? 0 : 1);
327 if ( (SSF_HIDEICONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideIcons", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
328 lpsfs
->fHideIcons
= ((dwData
== 0) ? 0 : 1);
330 if ( (SSF_MAPNETDRVBUTTON
& dwMask
) && !RegQueryValueExA(hKey
, "MapNetDrvBtn", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
331 lpsfs
->fMapNetDrvBtn
= ((dwData
== 0) ? 0 : 1);
333 if ( (SSF_SHOWATTRIBCOL
& dwMask
) && !RegQueryValueExA(hKey
, "ShowAttribCol", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
334 lpsfs
->fShowAttribCol
= ((dwData
== 0) ? 0 : 1);
336 if (((SSF_SHOWALLOBJECTS
| SSF_SHOWSYSFILES
) & dwMask
) && !RegQueryValueExA(hKey
, "Hidden", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
338 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
339 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
341 else if (dwData
== 1)
342 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 1;
343 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
345 else if (dwData
== 2)
346 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
347 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 1;
352 TRACE("-- 0x%04x\n", *(WORD
*)lpsfs
);
355 /*************************************************************************
356 * SHShellFolderView_Message [SHELL32.73]
358 * Send a message to an explorer cabinet window.
361 * hwndCabinet [I] The window containing the shellview to communicate with
362 * dwMessage [I] The SFVM message to send
363 * dwParam [I] Message parameter
369 * Message SFVM_REARRANGE = 1
371 * This message gets sent when a column gets clicked to instruct the
372 * shell view to re-sort the item list. dwParam identifies the column
375 LRESULT WINAPI
SHShellFolderView_Message(
380 FIXME("%p %08x %08lx stub\n",hwndCabinet
, uMessage
, lParam
);
384 /*************************************************************************
385 * RegisterShellHook [SHELL32.181]
387 * Register a shell hook.
390 * hwnd [I] Window handle
391 * dwType [I] Type of hook.
394 * Exported by ordinal
396 BOOL WINAPI
RegisterShellHook(
400 FIXME("(%p,0x%08x):stub.\n",hWnd
, dwType
);
404 /*************************************************************************
405 * ShellMessageBoxW [SHELL32.182]
407 * See ShellMessageBoxA.
410 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
411 * because we can't forward to it in the .spec file since it's exported by
412 * ordinal. If you change the implementation here please update the code in
415 int WINAPIV
ShellMessageBoxW(
423 WCHAR szText
[100],szTitle
[100];
424 LPCWSTR pszText
= szText
, pszTitle
= szTitle
;
429 __ms_va_start(args
, uType
);
430 /* wvsprintfA(buf,fmt, args); */
432 TRACE("(%p,%p,%p,%p,%08x)\n",
433 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
435 if (IS_INTRESOURCE(lpCaption
))
436 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]));
438 pszTitle
= lpCaption
;
440 if (IS_INTRESOURCE(lpText
))
441 LoadStringW(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
)/sizeof(szText
[0]));
445 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
446 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
450 ret
= MessageBoxW(hWnd
,pszTemp
,pszTitle
,uType
);
455 /*************************************************************************
456 * ShellMessageBoxA [SHELL32.183]
458 * Format and output an error message.
461 * hInstance [I] Instance handle of message creator
462 * hWnd [I] Window handle of message creator
463 * lpText [I] Resource Id of title or LPSTR
464 * lpCaption [I] Resource Id of title or LPSTR
465 * uType [I] Type of error message
468 * A return value from MessageBoxA().
471 * Exported by ordinal
473 int WINAPIV
ShellMessageBoxA(
481 char szText
[100],szTitle
[100];
482 LPCSTR pszText
= szText
, pszTitle
= szTitle
;
487 __ms_va_start(args
, uType
);
488 /* wvsprintfA(buf,fmt, args); */
490 TRACE("(%p,%p,%p,%p,%08x)\n",
491 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
493 if (IS_INTRESOURCE(lpCaption
))
494 LoadStringA(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
));
496 pszTitle
= lpCaption
;
498 if (IS_INTRESOURCE(lpText
))
499 LoadStringA(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
));
503 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
504 pszText
, 0, 0, (LPSTR
)&pszTemp
, 0, &args
);
508 ret
= MessageBoxA(hWnd
,pszTemp
,pszTitle
,uType
);
513 /*************************************************************************
514 * SHRegisterDragDrop [SHELL32.86]
516 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
517 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
518 * for details. Under Windows 98 this function initializes the true OLE when called
519 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
521 * We follow Windows 98 behaviour.
524 * exported by ordinal
527 * RegisterDragDrop, SHLoadOLE
529 HRESULT WINAPI
SHRegisterDragDrop(
531 LPDROPTARGET pDropTarget
)
533 static BOOL ole_initialized
= FALSE
;
536 TRACE("(%p,%p)\n", hWnd
, pDropTarget
);
538 if (!ole_initialized
)
540 hr
= OleInitialize(NULL
);
543 ole_initialized
= TRUE
;
545 return RegisterDragDrop(hWnd
, pDropTarget
);
548 /*************************************************************************
549 * SHRevokeDragDrop [SHELL32.87]
551 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
552 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
553 * for details. Function removed from Windows Vista.
555 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
559 * exported by ordinal
562 * RevokeDragDrop, SHLoadOLE
564 HRESULT WINAPI
SHRevokeDragDrop(HWND hWnd
)
566 TRACE("(%p)\n", hWnd
);
567 return RevokeDragDrop(hWnd
);
570 /*************************************************************************
571 * SHDoDragDrop [SHELL32.88]
573 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
574 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
578 * exported by ordinal
581 * DoDragDrop, SHLoadOLE
583 HRESULT WINAPI
SHDoDragDrop(
585 LPDATAOBJECT lpDataObject
,
586 LPDROPSOURCE lpDropSource
,
590 FIXME("(%p %p %p 0x%08x %p):stub.\n",
591 hWnd
, lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
592 return DoDragDrop(lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
595 /*************************************************************************
596 * ArrangeWindows [SHELL32.184]
599 WORD WINAPI
ArrangeWindows(
606 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
607 hwndParent
, dwReserved
, lpRect
, cKids
, lpKids
);
611 /*************************************************************************
612 * SignalFileOpen [SHELL32.103]
615 * exported by ordinal
618 SignalFileOpen (DWORD dwParam1
)
620 FIXME("(0x%08x):stub.\n", dwParam1
);
625 /*************************************************************************
626 * SHADD_get_policy - helper function for SHAddToRecentDocs
629 * policy [IN] policy name (null termed string) to find
630 * type [OUT] ptr to DWORD to receive type
631 * buffer [OUT] ptr to area to hold data retrieved
632 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
636 * result of the SHQueryValueEx call
638 static INT
SHADD_get_policy(LPCSTR policy
, LPDWORD type
, LPVOID buffer
, LPDWORD len
)
643 /* Get the key for the policies location in the registry
645 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
646 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
647 0, KEY_READ
, &Policy_basekey
)) {
649 if (RegOpenKeyExA(HKEY_CURRENT_USER
,
650 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
651 0, KEY_READ
, &Policy_basekey
)) {
652 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
655 return ERROR_FILE_NOT_FOUND
;
659 /* Retrieve the data if it exists
661 ret
= SHQueryValueExA(Policy_basekey
, policy
, 0, type
, buffer
, len
);
662 RegCloseKey(Policy_basekey
);
667 /*************************************************************************
668 * SHADD_compare_mru - helper function for SHAddToRecentDocs
671 * data1 [IN] data being looked for
672 * data2 [IN] data in MRU
673 * cbdata [IN] length from FindMRUData call (not used)
676 * position within MRU list that data was added.
678 static INT CALLBACK
SHADD_compare_mru(LPCVOID data1
, LPCVOID data2
, DWORD cbData
)
680 return lstrcmpiA(data1
, data2
);
683 /*************************************************************************
684 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
687 * mruhandle [IN] handle for created MRU list
688 * doc_name [IN] null termed pure doc name
689 * new_lnk_name [IN] null termed path and file name for .lnk file
690 * buffer [IN/OUT] 2048 byte area to construct MRU data
691 * len [OUT] ptr to int to receive space used in buffer
694 * position within MRU list that data was added.
696 static INT
SHADD_create_add_mru_data(HANDLE mruhandle
, LPCSTR doc_name
, LPCSTR new_lnk_name
,
697 LPSTR buffer
, INT
*len
)
703 * RecentDocs MRU data structure seems to be:
704 * +0h document file name w/ terminating 0h
705 * +nh short int w/ size of remaining
706 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
707 * +n+4h 10 bytes zeros - unknown
708 * +n+eh shortcut file name w/ terminating 0h
709 * +n+e+nh 3 zero bytes - unknown
712 /* Create the MRU data structure for "RecentDocs"
715 lstrcpyA(ptr
, doc_name
);
716 ptr
+= (lstrlenA(buffer
) + 1);
717 wlen
= lstrlenA(new_lnk_name
) + 1 + 12;
718 *((short int*)ptr
) = wlen
;
719 ptr
+= 2; /* step past the length */
720 *(ptr
++) = 0x30; /* unknown reason */
721 *(ptr
++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
724 lstrcpyA(ptr
, new_lnk_name
);
725 ptr
+= (lstrlenA(new_lnk_name
) + 1);
730 /* Add the new entry into the MRU list
732 return AddMRUData(mruhandle
, buffer
, *len
);
735 /*************************************************************************
736 * SHAddToRecentDocs [SHELL32.@]
738 * Modify (add/clear) Shell's list of recently used documents.
741 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
742 * pv [IN] string or pidl, NULL clears the list
750 void WINAPI
SHAddToRecentDocs (UINT uFlags
,LPCVOID pv
)
752 /* If list is a string list lpfnCompare has the following prototype
753 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
754 * for binary lists the prototype is
755 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
756 * where cbData is the no. of bytes to compare.
757 * Need to check what return value means identical - 0?
763 CHAR doc_name
[MAX_PATH
];
764 CHAR link_dir
[MAX_PATH
];
765 CHAR new_lnk_filepath
[MAX_PATH
];
766 CHAR new_lnk_name
[MAX_PATH
];
769 HWND hwnd
= 0; /* FIXME: get real window handle */
771 DWORD data
[64], datalen
, type
;
773 TRACE("%04x %p\n", uFlags
, pv
);
776 * RecentDocs MRU data structure seems to be:
777 * +0h document file name w/ terminating 0h
778 * +nh short int w/ size of remaining
779 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
780 * +n+4h 10 bytes zeros - unknown
781 * +n+eh shortcut file name w/ terminating 0h
782 * +n+e+nh 3 zero bytes - unknown
785 /* See if we need to do anything.
788 ret
=SHADD_get_policy( "NoRecentDocsHistory", &type
, data
, &datalen
);
789 if ((ret
> 0) && (ret
!= ERROR_FILE_NOT_FOUND
)) {
790 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret
);
793 if (ret
== ERROR_SUCCESS
) {
794 if (!( (type
== REG_DWORD
) ||
795 ((type
== REG_BINARY
) && (datalen
== 4)) )) {
796 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
801 TRACE("policy value for NoRecentDocsHistory = %08x\n", data
[0]);
802 /* now test the actual policy value */
807 /* Open key to where the necessary info is
809 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
810 * and the close should be done during the _DETACH. The resulting
811 * key is stored in the DLL global data.
813 if (RegCreateKeyExA(HKEY_CURRENT_USER
,
814 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
815 0, 0, 0, KEY_READ
, 0, &HCUbasekey
, 0)) {
816 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
820 /* Get path to user's "Recent" directory
822 if(SUCCEEDED(SHGetMalloc(&ppM
))) {
823 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd
, CSIDL_RECENT
,
825 SHGetPathFromIDListA(pidl
, link_dir
);
826 IMalloc_Free(ppM
, pidl
);
831 ERR("serious issues 1\n");
833 IMalloc_Release(ppM
);
838 ERR("serious issues 2\n");
840 TRACE("Users Recent dir %s\n", link_dir
);
842 /* If no input, then go clear the lists */
844 /* clear user's Recent dir
847 /* FIXME: delete all files in "link_dir"
849 * while( more files ) {
850 * lstrcpyA(old_lnk_name, link_dir);
851 * PathAppendA(old_lnk_name, filenam);
852 * DeleteFileA(old_lnk_name);
855 FIXME("should delete all files in %s\\\n", link_dir
);
859 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
860 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
861 * and naturally it fails w/ rc=2. It should do it against
862 * HKEY_CURRENT_USER which is where it is stored, and where
863 * the MRU routines expect it!!!!
865 RegDeleteKeyA(HCUbasekey
, "RecentDocs");
866 RegCloseKey(HCUbasekey
);
870 /* Have data to add, the jobs to be done:
871 * 1. Add document to MRU list in registry "HKCU\Software\
872 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
873 * 2. Add shortcut to document in the user's Recent directory
875 * 3. Add shortcut to Start menu's Documents submenu.
878 /* Get the pure document name from the input
883 SHGetPathFromIDListA(pv
, doc_name
);
887 lstrcpynA(doc_name
, pv
, MAX_PATH
);
891 WideCharToMultiByte(CP_ACP
, 0, pv
, -1, doc_name
, MAX_PATH
, NULL
, NULL
);
895 FIXME("Unsupported flags: %u\n", uFlags
);
899 TRACE("full document name %s\n", debugstr_a(doc_name
));
900 PathStripPathA(doc_name
);
901 TRACE("stripped document name %s\n", debugstr_a(doc_name
));
904 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
907 * doc_name - pure file-spec, no path
908 * link_dir - path to the user's Recent directory
909 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
911 * new_lnk_name- pure file-spec, no path for new .lnk file
913 * - path and file name of new .lnk file
915 CREATEMRULISTA mymru
;
917 INT len
, pos
, bufused
, err
;
922 CHAR old_lnk_name
[MAX_PATH
];
925 mymru
.cbSize
= sizeof(CREATEMRULISTA
);
926 mymru
.nMaxItems
= 15;
927 mymru
.dwFlags
= MRUF_BINARY_LIST
| MRUF_DELAYED_SAVE
;
928 mymru
.hKey
= HCUbasekey
;
929 mymru
.lpszSubKey
= "RecentDocs";
930 mymru
.lpfnCompare
= (PROC
)SHADD_compare_mru
;
931 mruhandle
= CreateMRUListA(&mymru
);
934 ERR("MRU processing failed, handle zero\n");
935 RegCloseKey(HCUbasekey
);
938 len
= lstrlenA(doc_name
);
939 pos
= FindMRUData(mruhandle
, doc_name
, len
, 0);
941 /* Now get the MRU entry that will be replaced
942 * and delete the .lnk file for it
944 if ((bufused
= EnumMRUListA(mruhandle
, (pos
== -1) ? 14 : pos
,
945 buffer
, 2048)) != -1) {
947 ptr
+= (lstrlenA(buffer
) + 1);
948 slen
= *((short int*)ptr
);
949 ptr
+= 2; /* skip the length area */
950 if (bufused
>= slen
+ (ptr
-buffer
)) {
951 /* buffer size looks good */
952 ptr
+= 12; /* get to string */
953 len
= bufused
- (ptr
-buffer
); /* get length of buf remaining */
954 if ((lstrlenA(ptr
) > 0) && (lstrlenA(ptr
) <= len
-1)) {
955 /* appears to be good string */
956 lstrcpyA(old_lnk_name
, link_dir
);
957 PathAppendA(old_lnk_name
, ptr
);
958 if (!DeleteFileA(old_lnk_name
)) {
959 if ((attr
= GetFileAttributesA(old_lnk_name
)) == INVALID_FILE_ATTRIBUTES
) {
960 if ((err
= GetLastError()) != ERROR_FILE_NOT_FOUND
) {
961 ERR("Delete for %s failed, err=%d, attr=%08x\n",
962 old_lnk_name
, err
, attr
);
965 TRACE("old .lnk file %s did not exist\n",
970 ERR("Delete for %s failed, attr=%08x\n",
975 TRACE("deleted old .lnk file %s\n", old_lnk_name
);
981 /* Create usable .lnk file name for the "Recent" directory
983 wsprintfA(new_lnk_name
, "%s.lnk", doc_name
);
984 lstrcpyA(new_lnk_filepath
, link_dir
);
985 PathAppendA(new_lnk_filepath
, new_lnk_name
);
987 olderrormode
= SetErrorMode(SEM_FAILCRITICALERRORS
);
988 while (GetFileAttributesA(new_lnk_filepath
) != INVALID_FILE_ATTRIBUTES
) {
990 wsprintfA(new_lnk_name
, "%s (%u).lnk", doc_name
, i
);
991 lstrcpyA(new_lnk_filepath
, link_dir
);
992 PathAppendA(new_lnk_filepath
, new_lnk_name
);
994 SetErrorMode(olderrormode
);
995 TRACE("new shortcut will be %s\n", new_lnk_filepath
);
997 /* Now add the new MRU entry and data
999 pos
= SHADD_create_add_mru_data(mruhandle
, doc_name
, new_lnk_name
,
1001 FreeMRUList(mruhandle
);
1002 TRACE("Updated MRU list, new doc is position %d\n", pos
);
1005 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
1007 { /* on input needs:
1008 * doc_name - pure file-spec, no path
1010 * - path and file name of new .lnk file
1011 * uFlags[in] - flags on call to SHAddToRecentDocs
1012 * pv[in] - document path/pidl on call to SHAddToRecentDocs
1014 IShellLinkA
*psl
= NULL
;
1015 IPersistFile
*pPf
= NULL
;
1017 CHAR desc
[MAX_PATH
];
1018 WCHAR widelink
[MAX_PATH
];
1022 hres
= CoCreateInstance( &CLSID_ShellLink
,
1024 CLSCTX_INPROC_SERVER
,
1027 if(SUCCEEDED(hres
)) {
1029 hres
= IShellLinkA_QueryInterface(psl
, &IID_IPersistFile
,
1033 ERR("failed QueryInterface for IPersistFile %08x\n", hres
);
1037 /* Set the document path or pidl */
1038 if (uFlags
== SHARD_PIDL
) {
1039 hres
= IShellLinkA_SetIDList(psl
, pv
);
1041 hres
= IShellLinkA_SetPath(psl
, pv
);
1045 ERR("failed Set{IDList|Path} %08x\n", hres
);
1049 lstrcpyA(desc
, "Shortcut to ");
1050 lstrcatA(desc
, doc_name
);
1051 hres
= IShellLinkA_SetDescription(psl
, desc
);
1054 ERR("failed SetDescription %08x\n", hres
);
1058 MultiByteToWideChar(CP_ACP
, 0, new_lnk_filepath
, -1,
1059 widelink
, MAX_PATH
);
1060 /* create the short cut */
1061 hres
= IPersistFile_Save(pPf
, widelink
, TRUE
);
1064 ERR("failed IPersistFile::Save %08x\n", hres
);
1065 IPersistFile_Release(pPf
);
1066 IShellLinkA_Release(psl
);
1069 hres
= IPersistFile_SaveCompleted(pPf
, widelink
);
1070 IPersistFile_Release(pPf
);
1071 IShellLinkA_Release(psl
);
1072 TRACE("shortcut %s has been created, result=%08x\n",
1073 new_lnk_filepath
, hres
);
1076 ERR("CoCreateInstance failed, hres=%08x\n", hres
);
1084 RegCloseKey(HCUbasekey
);
1088 /*************************************************************************
1089 * SHCreateShellFolderViewEx [SHELL32.174]
1091 * Create a new instance of the default Shell folder view object.
1095 * Failure: error value
1098 * see IShellFolder::CreateViewObject
1100 HRESULT WINAPI
SHCreateShellFolderViewEx(
1101 LPCSFV psvcbi
, /* [in] shelltemplate struct */
1102 IShellView
**ppv
) /* [out] IShellView pointer */
1107 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1108 psvcbi
->pshf
, psvcbi
->pidl
, psvcbi
->pfnCallback
,
1109 psvcbi
->fvm
, psvcbi
->psvOuter
);
1111 psf
= IShellView_Constructor(psvcbi
->pshf
);
1114 return E_OUTOFMEMORY
;
1116 IShellView_AddRef(psf
);
1117 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppv
);
1118 IShellView_Release(psf
);
1122 /*************************************************************************
1123 * SHWinHelp [SHELL32.127]
1126 HRESULT WINAPI
SHWinHelp (DWORD v
, DWORD w
, DWORD x
, DWORD z
)
1127 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v
,w
,x
,z
);
1130 /*************************************************************************
1131 * SHRunControlPanel [SHELL32.161]
1134 HRESULT WINAPI
SHRunControlPanel (DWORD x
, DWORD z
)
1135 { FIXME("0x%08x 0x%08x stub\n",x
,z
);
1139 static LPUNKNOWN SHELL32_IExplorerInterface
=0;
1140 /*************************************************************************
1141 * SHSetInstanceExplorer [SHELL32.176]
1144 * Sets the interface
1146 VOID WINAPI
SHSetInstanceExplorer (LPUNKNOWN lpUnknown
)
1147 { TRACE("%p\n", lpUnknown
);
1148 SHELL32_IExplorerInterface
= lpUnknown
;
1150 /*************************************************************************
1151 * SHGetInstanceExplorer [SHELL32.@]
1154 * gets the interface pointer of the explorer and a reference
1156 HRESULT WINAPI
SHGetInstanceExplorer (IUnknown
**lpUnknown
)
1157 { TRACE("%p\n", lpUnknown
);
1159 *lpUnknown
= SHELL32_IExplorerInterface
;
1161 if (!SHELL32_IExplorerInterface
)
1164 IUnknown_AddRef(SHELL32_IExplorerInterface
);
1167 /*************************************************************************
1168 * SHFreeUnusedLibraries [SHELL32.123]
1170 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1171 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1175 * exported by ordinal
1178 * CoFreeUnusedLibraries, SHLoadOLE
1180 void WINAPI
SHFreeUnusedLibraries (void)
1183 CoFreeUnusedLibraries();
1185 /*************************************************************************
1186 * DAD_AutoScroll [SHELL32.129]
1189 BOOL WINAPI
DAD_AutoScroll(HWND hwnd
, AUTO_SCROLL_DATA
*samples
, LPPOINT pt
)
1191 FIXME("hwnd = %p %p %p\n",hwnd
,samples
,pt
);
1194 /*************************************************************************
1195 * DAD_DragEnter [SHELL32.130]
1198 BOOL WINAPI
DAD_DragEnter(HWND hwnd
)
1200 FIXME("hwnd = %p\n",hwnd
);
1203 /*************************************************************************
1204 * DAD_DragEnterEx [SHELL32.131]
1207 BOOL WINAPI
DAD_DragEnterEx(HWND hwnd
, POINT p
)
1209 FIXME("hwnd = %p (%d,%d)\n",hwnd
,p
.x
,p
.y
);
1212 /*************************************************************************
1213 * DAD_DragMove [SHELL32.134]
1216 BOOL WINAPI
DAD_DragMove(POINT p
)
1218 FIXME("(%d,%d)\n",p
.x
,p
.y
);
1221 /*************************************************************************
1222 * DAD_DragLeave [SHELL32.132]
1225 BOOL WINAPI
DAD_DragLeave(VOID
)
1230 /*************************************************************************
1231 * DAD_SetDragImage [SHELL32.136]
1236 BOOL WINAPI
DAD_SetDragImage(
1237 HIMAGELIST himlTrack
,
1240 FIXME("%p %p stub\n",himlTrack
, lppt
);
1243 /*************************************************************************
1244 * DAD_ShowDragImage [SHELL32.137]
1249 BOOL WINAPI
DAD_ShowDragImage(BOOL bShow
)
1251 FIXME("0x%08x stub\n",bShow
);
1255 static const WCHAR szwCabLocation
[] = {
1256 'S','o','f','t','w','a','r','e','\\',
1257 'M','i','c','r','o','s','o','f','t','\\',
1258 'W','i','n','d','o','w','s','\\',
1259 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1260 'E','x','p','l','o','r','e','r','\\',
1261 'C','a','b','i','n','e','t','S','t','a','t','e',0
1264 static const WCHAR szwSettings
[] = { 'S','e','t','t','i','n','g','s',0 };
1266 /*************************************************************************
1267 * ReadCabinetState [SHELL32.651] NT 4.0
1270 BOOL WINAPI
ReadCabinetState(CABINETSTATE
*cs
, int length
)
1275 TRACE("%p %d\n", cs
, length
);
1277 if( (cs
== NULL
) || (length
< (int)sizeof(*cs
)) )
1280 r
= RegOpenKeyW( HKEY_CURRENT_USER
, szwCabLocation
, &hkey
);
1281 if( r
== ERROR_SUCCESS
)
1284 r
= RegQueryValueExW( hkey
, szwSettings
,
1285 NULL
, &type
, (LPBYTE
)cs
, (LPDWORD
)&length
);
1286 RegCloseKey( hkey
);
1290 /* if we can't read from the registry, create default values */
1291 if ( (r
!= ERROR_SUCCESS
) || (cs
->cLength
< sizeof(*cs
)) ||
1292 (cs
->cLength
!= length
) )
1294 ERR("Initializing shell cabinet settings\n");
1295 memset(cs
, 0, sizeof(*cs
));
1296 cs
->cLength
= sizeof(*cs
);
1298 cs
->fFullPathTitle
= FALSE
;
1299 cs
->fSaveLocalView
= TRUE
;
1300 cs
->fNotShell
= FALSE
;
1301 cs
->fSimpleDefault
= TRUE
;
1302 cs
->fDontShowDescBar
= FALSE
;
1303 cs
->fNewWindowMode
= FALSE
;
1304 cs
->fShowCompColor
= FALSE
;
1305 cs
->fDontPrettyNames
= FALSE
;
1306 cs
->fAdminsCreateCommonGroups
= TRUE
;
1307 cs
->fMenuEnumFilter
= 96;
1313 /*************************************************************************
1314 * WriteCabinetState [SHELL32.652] NT 4.0
1317 BOOL WINAPI
WriteCabinetState(CABINETSTATE
*cs
)
1327 r
= RegCreateKeyExW( HKEY_CURRENT_USER
, szwCabLocation
, 0,
1328 NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
1329 if( r
== ERROR_SUCCESS
)
1331 r
= RegSetValueExW( hkey
, szwSettings
, 0,
1332 REG_BINARY
, (LPBYTE
) cs
, cs
->cLength
);
1334 RegCloseKey( hkey
);
1337 return (r
==ERROR_SUCCESS
);
1340 /*************************************************************************
1341 * FileIconInit [SHELL32.660]
1344 BOOL WINAPI
FileIconInit(BOOL bFullInit
)
1345 { FIXME("(%s)\n", bFullInit
? "true" : "false");
1349 /*************************************************************************
1350 * IsUserAnAdmin [SHELL32.680] NT 4.0
1352 * Checks whether the current user is a member of the Administrators group.
1361 BOOL WINAPI
IsUserAnAdmin(VOID
)
1363 SID_IDENTIFIER_AUTHORITY Authority
= {SECURITY_NT_AUTHORITY
};
1366 PTOKEN_GROUPS lpGroups
;
1369 BOOL bResult
= FALSE
;
1372 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &hToken
))
1377 if (!GetTokenInformation(hToken
, TokenGroups
, NULL
, 0, &dwSize
))
1379 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
1381 CloseHandle(hToken
);
1386 lpGroups
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
1387 if (lpGroups
== NULL
)
1389 CloseHandle(hToken
);
1393 if (!GetTokenInformation(hToken
, TokenGroups
, lpGroups
, dwSize
, &dwSize
))
1395 HeapFree(GetProcessHeap(), 0, lpGroups
);
1396 CloseHandle(hToken
);
1400 CloseHandle(hToken
);
1401 if (!AllocateAndInitializeSid(&Authority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
1402 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0,
1405 HeapFree(GetProcessHeap(), 0, lpGroups
);
1409 for (i
= 0; i
< lpGroups
->GroupCount
; i
++)
1411 if (EqualSid(lpSid
, lpGroups
->Groups
[i
].Sid
))
1419 HeapFree(GetProcessHeap(), 0, lpGroups
);
1423 /*************************************************************************
1424 * SHAllocShared [SHELL32.520]
1426 * See shlwapi.SHAllocShared
1428 HANDLE WINAPI
SHAllocShared(LPVOID lpvData
, DWORD dwSize
, DWORD dwProcId
)
1430 GET_FUNC(pSHAllocShared
, shlwapi
, (char*)7, NULL
);
1431 return pSHAllocShared(lpvData
, dwSize
, dwProcId
);
1434 /*************************************************************************
1435 * SHLockShared [SHELL32.521]
1437 * See shlwapi.SHLockShared
1439 LPVOID WINAPI
SHLockShared(HANDLE hShared
, DWORD dwProcId
)
1441 GET_FUNC(pSHLockShared
, shlwapi
, (char*)8, NULL
);
1442 return pSHLockShared(hShared
, dwProcId
);
1445 /*************************************************************************
1446 * SHUnlockShared [SHELL32.522]
1448 * See shlwapi.SHUnlockShared
1450 BOOL WINAPI
SHUnlockShared(LPVOID lpView
)
1452 GET_FUNC(pSHUnlockShared
, shlwapi
, (char*)9, FALSE
);
1453 return pSHUnlockShared(lpView
);
1456 /*************************************************************************
1457 * SHFreeShared [SHELL32.523]
1459 * See shlwapi.SHFreeShared
1461 BOOL WINAPI
SHFreeShared(HANDLE hShared
, DWORD dwProcId
)
1463 GET_FUNC(pSHFreeShared
, shlwapi
, (char*)10, FALSE
);
1464 return pSHFreeShared(hShared
, dwProcId
);
1467 /*************************************************************************
1468 * SetAppStartingCursor [SHELL32.99]
1470 HRESULT WINAPI
SetAppStartingCursor(HWND u
, DWORD v
)
1471 { FIXME("hwnd=%p 0x%04x stub\n",u
,v
);
1475 /*************************************************************************
1476 * SHLoadOLE [SHELL32.151]
1478 * To reduce the memory usage of Windows 95, its shell32 contained an
1479 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1480 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1481 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1482 * would just call the Co* functions.
1484 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1485 * information from the shell32 "mini-COM" to ole32.dll.
1487 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1488 * detailed description.
1490 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1491 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1492 * hack in SHCoCreateInstance)
1494 HRESULT WINAPI
SHLoadOLE(LPARAM lParam
)
1495 { FIXME("0x%08lx stub\n",lParam
);
1498 /*************************************************************************
1499 * DriveType [SHELL32.64]
1502 HRESULT WINAPI
DriveType(DWORD u
)
1503 { FIXME("0x%04x stub\n",u
);
1506 /*************************************************************************
1507 * InvalidateDriveType [SHELL32.65]
1510 int WINAPI
InvalidateDriveType(int u
)
1511 { FIXME("0x%08x stub\n",u
);
1514 /*************************************************************************
1515 * SHAbortInvokeCommand [SHELL32.198]
1518 HRESULT WINAPI
SHAbortInvokeCommand(void)
1522 /*************************************************************************
1523 * SHOutOfMemoryMessageBox [SHELL32.126]
1526 int WINAPI
SHOutOfMemoryMessageBox(
1531 FIXME("%p %s 0x%08x stub\n",hwndOwner
, lpCaption
, uType
);
1534 /*************************************************************************
1535 * SHFlushClipboard [SHELL32.121]
1538 HRESULT WINAPI
SHFlushClipboard(void)
1543 /*************************************************************************
1544 * SHWaitForFileToOpen [SHELL32.97]
1547 BOOL WINAPI
SHWaitForFileToOpen(
1552 FIXME("%p 0x%08x 0x%08x stub\n", pidl
, dwFlags
, dwTimeout
);
1556 /************************************************************************
1560 * first parameter seems to be a pointer (same as passed to WriteCabinetState)
1561 * second one could be a size (0x0c). The size is the same as the structure saved to
1562 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1563 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1565 HRESULT WINAPI
shell32_654 (CABINETSTATE
*cs
, int length
)
1567 TRACE("%p %d\n",cs
,length
);
1568 return ReadCabinetState(cs
,length
);
1571 /************************************************************************
1572 * RLBuildListOfPaths [SHELL32.146]
1577 DWORD WINAPI
RLBuildListOfPaths (void)
1581 /************************************************************************
1582 * SHValidateUNC [SHELL32.173]
1585 HRESULT WINAPI
SHValidateUNC (DWORD x
, DWORD y
, DWORD z
)
1587 FIXME("0x%08x 0x%08x 0x%08x stub\n",x
,y
,z
);
1591 /************************************************************************
1592 * DoEnvironmentSubstA [SHELL32.@]
1594 * Replace %KEYWORD% in the str with the value of variable KEYWORD
1595 * from environment. If it is not found the %KEYWORD% is left
1596 * intact. If the buffer is too small, str is not modified.
1599 * pszString [I] '\0' terminated string with %keyword%.
1600 * [O] '\0' terminated string with %keyword% substituted.
1601 * cchString [I] size of str.
1604 * cchString length in the HIWORD;
1605 * TRUE in LOWORD if subst was successful and FALSE in other case
1607 DWORD WINAPI
DoEnvironmentSubstA(LPSTR pszString
, UINT cchString
)
1611 FIXME("(%s, %d) stub\n", debugstr_a(pszString
), cchString
);
1612 if (pszString
== NULL
) /* Really return 0? */
1614 if ((dst
= HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(CHAR
))))
1616 DWORD num
= ExpandEnvironmentStringsA(pszString
, dst
, cchString
);
1617 if (num
&& num
< cchString
) /* dest buffer is too small */
1620 memcpy(pszString
, dst
, num
);
1622 HeapFree(GetProcessHeap(), 0, dst
);
1624 return MAKELONG(res
,cchString
); /* Always cchString? */
1627 /************************************************************************
1628 * DoEnvironmentSubstW [SHELL32.@]
1630 * See DoEnvironmentSubstA.
1632 DWORD WINAPI
DoEnvironmentSubstW(LPWSTR pszString
, UINT cchString
)
1634 FIXME("(%s, %d): stub\n", debugstr_w(pszString
), cchString
);
1635 return MAKELONG(FALSE
,cchString
);
1638 /************************************************************************
1639 * DoEnvironmentSubst [SHELL32.53]
1641 * See DoEnvironmentSubstA.
1643 DWORD WINAPI
DoEnvironmentSubstAW(LPVOID x
, UINT y
)
1645 if (SHELL_OsIsUnicode())
1646 return DoEnvironmentSubstW(x
, y
);
1647 return DoEnvironmentSubstA(x
, y
);
1650 /*************************************************************************
1653 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1654 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1658 BOOL WINAPI
shell32_243(DWORD a
, DWORD b
)
1663 /*************************************************************************
1664 * GUIDFromStringW [SHELL32.704]
1666 BOOL WINAPI
GUIDFromStringW(LPCWSTR str
, LPGUID guid
)
1668 UNICODE_STRING guid_str
;
1670 RtlInitUnicodeString(&guid_str
, str
);
1671 return !RtlGUIDFromString(&guid_str
, guid
);
1674 /*************************************************************************
1677 DWORD WINAPI
SHELL32_714(LPVOID x
)
1679 FIXME("(%s)stub\n", debugstr_w(x
));
1683 typedef struct _PSXA
1687 IShellPropSheetExt
*pspsx
[1];
1690 typedef struct _PSXA_CALL
1692 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith
;
1697 } PSXA_CALL
, *PPSXA_CALL
;
1699 static BOOL CALLBACK
PsxaCall(HPROPSHEETPAGE hpage
, LPARAM lParam
)
1701 PPSXA_CALL Call
= (PPSXA_CALL
)lParam
;
1705 if ((Call
->bMultiple
|| !Call
->bCalled
) &&
1706 Call
->lpfnAddReplaceWith(hpage
, Call
->lParam
))
1708 Call
->bCalled
= TRUE
;
1717 /*************************************************************************
1718 * SHAddFromPropSheetExtArray [SHELL32.167]
1720 UINT WINAPI
SHAddFromPropSheetExtArray(HPSXA hpsxa
, LPFNADDPROPSHEETPAGE lpfnAddPage
, LPARAM lParam
)
1724 PPSXA psxa
= (PPSXA
)hpsxa
;
1726 TRACE("(%p,%p,%08lx)\n", hpsxa
, lpfnAddPage
, lParam
);
1730 ZeroMemory(&Call
, sizeof(Call
));
1731 Call
.lpfnAddReplaceWith
= lpfnAddPage
;
1732 Call
.lParam
= lParam
;
1733 Call
.bMultiple
= TRUE
;
1735 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1736 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1738 psxa
->pspsx
[i
]->lpVtbl
->AddPages(psxa
->pspsx
[i
], PsxaCall
, (LPARAM
)&Call
);
1741 return Call
.uiCount
;
1747 /*************************************************************************
1748 * SHCreatePropSheetExtArray [SHELL32.168]
1750 HPSXA WINAPI
SHCreatePropSheetExtArray(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
)
1752 return SHCreatePropSheetExtArrayEx(hKey
, pszSubKey
, max_iface
, NULL
);
1755 /*************************************************************************
1756 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1758 HPSXA WINAPI
SHCreatePropSheetExtArrayEx(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
, LPDATAOBJECT pDataObj
)
1760 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};
1761 WCHAR szHandler
[64];
1763 WCHAR szClsidHandler
[39];
1768 IShellExtInit
*psxi
;
1769 IShellPropSheetExt
*pspsx
;
1770 HKEY hkBase
, hkPropSheetHandlers
;
1773 TRACE("(%p,%s,%u)\n", hKey
, debugstr_w(pszSubKey
), max_iface
);
1778 /* Open the registry key */
1779 lRet
= RegOpenKeyW(hKey
, pszSubKey
, &hkBase
);
1780 if (lRet
!= ERROR_SUCCESS
)
1783 lRet
= RegOpenKeyExW(hkBase
, szPropSheetSubKey
, 0, KEY_ENUMERATE_SUB_KEYS
, &hkPropSheetHandlers
);
1784 RegCloseKey(hkBase
);
1785 if (lRet
== ERROR_SUCCESS
)
1787 /* Create and initialize the Property Sheet Extensions Array */
1788 psxa
= LocalAlloc(LMEM_FIXED
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1791 ZeroMemory(psxa
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1792 psxa
->uiAllocated
= max_iface
;
1794 /* Enumerate all subkeys and attempt to load the shell extensions */
1798 dwHandlerLen
= sizeof(szHandler
) / sizeof(szHandler
[0]);
1799 lRet
= RegEnumKeyExW(hkPropSheetHandlers
, dwIndex
++, szHandler
, &dwHandlerLen
, NULL
, NULL
, NULL
, NULL
);
1800 if (lRet
!= ERROR_SUCCESS
)
1802 if (lRet
== ERROR_MORE_DATA
)
1805 if (lRet
== ERROR_NO_MORE_ITEMS
)
1806 lRet
= ERROR_SUCCESS
;
1810 /* The CLSID is stored either in the key itself or in its default value. */
1811 if (FAILED(lRet
= SHCLSIDFromStringW(szHandler
, &clsid
)))
1813 dwClsidSize
= sizeof(szClsidHandler
);
1814 if (SHGetValueW(hkPropSheetHandlers
, szHandler
, NULL
, NULL
, szClsidHandler
, &dwClsidSize
) == ERROR_SUCCESS
)
1816 /* Force a NULL-termination and convert the string */
1817 szClsidHandler
[(sizeof(szClsidHandler
) / sizeof(szClsidHandler
[0])) - 1] = 0;
1818 lRet
= SHCLSIDFromStringW(szClsidHandler
, &clsid
);
1822 if (SUCCEEDED(lRet
))
1824 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1825 Only if both interfaces are supported it's a real shell extension.
1826 Then call IShellExtInit's Initialize method. */
1827 if (SUCCEEDED(CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt
, (LPVOID
*)&pspsx
)))
1829 if (SUCCEEDED(pspsx
->lpVtbl
->QueryInterface(pspsx
, &IID_IShellExtInit
, (PVOID
*)&psxi
)))
1831 if (SUCCEEDED(psxi
->lpVtbl
->Initialize(psxi
, NULL
, pDataObj
, hKey
)))
1833 /* Add the IShellPropSheetExt instance to the array */
1834 psxa
->pspsx
[psxa
->uiCount
++] = pspsx
;
1838 psxi
->lpVtbl
->Release(psxi
);
1839 pspsx
->lpVtbl
->Release(pspsx
);
1843 pspsx
->lpVtbl
->Release(pspsx
);
1847 } while (psxa
->uiCount
!= psxa
->uiAllocated
);
1850 lRet
= ERROR_NOT_ENOUGH_MEMORY
;
1852 RegCloseKey(hkPropSheetHandlers
);
1855 if (lRet
!= ERROR_SUCCESS
&& psxa
)
1857 SHDestroyPropSheetExtArray((HPSXA
)psxa
);
1864 /*************************************************************************
1865 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1867 UINT WINAPI
SHReplaceFromPropSheetExtArray(HPSXA hpsxa
, UINT uPageID
, LPFNADDPROPSHEETPAGE lpfnReplaceWith
, LPARAM lParam
)
1871 PPSXA psxa
= (PPSXA
)hpsxa
;
1873 TRACE("(%p,%u,%p,%08lx)\n", hpsxa
, uPageID
, lpfnReplaceWith
, lParam
);
1877 ZeroMemory(&Call
, sizeof(Call
));
1878 Call
.lpfnAddReplaceWith
= lpfnReplaceWith
;
1879 Call
.lParam
= lParam
;
1881 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1882 Each shell extension is only allowed to call the callback once during the callback. */
1883 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1885 Call
.bCalled
= FALSE
;
1886 psxa
->pspsx
[i
]->lpVtbl
->ReplacePage(psxa
->pspsx
[i
], uPageID
, PsxaCall
, (LPARAM
)&Call
);
1889 return Call
.uiCount
;
1895 /*************************************************************************
1896 * SHDestroyPropSheetExtArray [SHELL32.169]
1898 void WINAPI
SHDestroyPropSheetExtArray(HPSXA hpsxa
)
1901 PPSXA psxa
= (PPSXA
)hpsxa
;
1903 TRACE("(%p)\n", hpsxa
);
1907 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1909 psxa
->pspsx
[i
]->lpVtbl
->Release(psxa
->pspsx
[i
]);
1916 /*************************************************************************
1917 * CIDLData_CreateFromIDArray [SHELL32.83]
1919 * Create IDataObject from PIDLs??
1921 HRESULT WINAPI
CIDLData_CreateFromIDArray(
1922 LPCITEMIDLIST pidlFolder
,
1924 LPCITEMIDLIST
*lppidlFiles
,
1925 LPDATAOBJECT
*ppdataObject
)
1928 HWND hwnd
= 0; /*FIXME: who should be hwnd of owner? set to desktop */
1930 TRACE("(%p, %d, %p, %p)\n", pidlFolder
, cpidlFiles
, lppidlFiles
, ppdataObject
);
1934 for (i
=0; i
<cpidlFiles
; i
++) pdump (lppidlFiles
[i
]);
1936 *ppdataObject
= IDataObject_Constructor( hwnd
, pidlFolder
,
1937 lppidlFiles
, cpidlFiles
);
1938 if (*ppdataObject
) return S_OK
;
1939 return E_OUTOFMEMORY
;
1942 /*************************************************************************
1943 * SHCreateStdEnumFmtEtc [SHELL32.74]
1948 HRESULT WINAPI
SHCreateStdEnumFmtEtc(
1950 const FORMATETC
*lpFormats
,
1951 LPENUMFORMATETC
*ppenumFormatetc
)
1953 IEnumFORMATETC
*pef
;
1955 TRACE("cf=%d fe=%p pef=%p\n", cFormats
, lpFormats
, ppenumFormatetc
);
1957 pef
= IEnumFORMATETC_Constructor(cFormats
, lpFormats
);
1959 return E_OUTOFMEMORY
;
1961 IEnumFORMATETC_AddRef(pef
);
1962 hRes
= IEnumFORMATETC_QueryInterface(pef
, &IID_IEnumFORMATETC
, (LPVOID
*)ppenumFormatetc
);
1963 IEnumFORMATETC_Release(pef
);
1968 /*************************************************************************
1969 * SHFindFiles (SHELL32.90)
1971 BOOL WINAPI
SHFindFiles( LPCITEMIDLIST pidlFolder
, LPCITEMIDLIST pidlSaveFile
)
1973 FIXME("%p %p\n", pidlFolder
, pidlSaveFile
);
1977 /*************************************************************************
1978 * SHUpdateImageW (SHELL32.192)
1980 * Notifies the shell that an icon in the system image list has been changed.
1983 * pszHashItem [I] Path to file that contains the icon.
1984 * iIndex [I] Zero-based index of the icon in the file.
1985 * uFlags [I] Flags determining the icon attributes. See notes.
1986 * iImageIndex [I] Index of the icon in the system image list.
1992 * uFlags can be one or more of the following flags:
1993 * GIL_NOTFILENAME - pszHashItem is not a file name.
1994 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1996 void WINAPI
SHUpdateImageW(LPCWSTR pszHashItem
, int iIndex
, UINT uFlags
, int iImageIndex
)
1998 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
2001 /*************************************************************************
2002 * SHUpdateImageA (SHELL32.191)
2004 * See SHUpdateImageW.
2006 VOID WINAPI
SHUpdateImageA(LPCSTR pszHashItem
, INT iIndex
, UINT uFlags
, INT iImageIndex
)
2008 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
2011 INT WINAPI
SHHandleUpdateImage(LPCITEMIDLIST pidlExtra
)
2013 FIXME("%p - stub\n", pidlExtra
);
2018 BOOL WINAPI
SHObjectProperties(HWND hwnd
, DWORD dwType
, LPCWSTR szObject
, LPCWSTR szPage
)
2020 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd
, dwType
, debugstr_w(szObject
), debugstr_w(szPage
));
2025 BOOL WINAPI
SHGetNewLinkInfoA(LPCSTR pszLinkTo
, LPCSTR pszDir
, LPSTR pszName
, BOOL
*pfMustCopy
,
2028 WCHAR wszLinkTo
[MAX_PATH
];
2029 WCHAR wszDir
[MAX_PATH
];
2030 WCHAR wszName
[MAX_PATH
];
2033 MultiByteToWideChar(CP_ACP
, 0, pszLinkTo
, -1, wszLinkTo
, MAX_PATH
);
2034 MultiByteToWideChar(CP_ACP
, 0, pszDir
, -1, wszDir
, MAX_PATH
);
2036 res
= SHGetNewLinkInfoW(wszLinkTo
, wszDir
, wszName
, pfMustCopy
, uFlags
);
2039 WideCharToMultiByte(CP_ACP
, 0, wszName
, -1, pszName
, MAX_PATH
, NULL
, NULL
);
2044 BOOL WINAPI
SHGetNewLinkInfoW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
, BOOL
*pfMustCopy
,
2047 const WCHAR
*basename
;
2048 WCHAR
*dst_basename
;
2050 static const WCHAR lnkformat
[] = {'%','s','.','l','n','k',0};
2051 static const WCHAR lnkformatnum
[] = {'%','s',' ','(','%','d',')','.','l','n','k',0};
2053 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo
), debugstr_w(pszDir
),
2054 pszName
, pfMustCopy
, uFlags
);
2056 *pfMustCopy
= FALSE
;
2058 if (uFlags
& SHGNLI_PIDL
)
2060 FIXME("SHGNLI_PIDL flag unsupported\n");
2065 FIXME("ignoring flags: 0x%08x\n", uFlags
);
2067 /* FIXME: should test if the file is a shortcut or DOS program */
2068 if (GetFileAttributesW(pszLinkTo
) == INVALID_FILE_ATTRIBUTES
)
2071 basename
= strrchrW(pszLinkTo
, '\\');
2073 basename
= basename
+1;
2075 basename
= pszLinkTo
;
2077 lstrcpynW(pszName
, pszDir
, MAX_PATH
);
2078 if (!PathAddBackslashW(pszName
))
2081 dst_basename
= pszName
+ strlenW(pszName
);
2083 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformat
, basename
);
2085 while (GetFileAttributesW(pszName
) != INVALID_FILE_ATTRIBUTES
)
2087 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformatnum
, basename
, i
);
2094 HRESULT WINAPI
SHStartNetConnectionDialog(HWND hwnd
, LPCSTR pszRemoteName
, DWORD dwType
)
2096 FIXME("%p, %s, 0x%08x - stub\n", hwnd
, debugstr_a(pszRemoteName
), dwType
);
2101 DWORD WINAPI
SHFormatDrive(HWND hwnd
, UINT drive
, UINT fmtID
, UINT options
)
2103 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd
, drive
, fmtID
, options
);
2105 return SHFMT_NOFORMAT
;
2108 /*************************************************************************
2109 * SHSetLocalizedName (SHELL32.@)
2111 HRESULT WINAPI
SHSetLocalizedName(LPWSTR pszPath
, LPCWSTR pszResModule
, int idsRes
)
2113 FIXME("%p, %s, %d - stub\n", pszPath
, debugstr_w(pszResModule
), idsRes
);
2118 /*************************************************************************
2119 * LinkWindow_RegisterClass (SHELL32.258)
2121 BOOL WINAPI
LinkWindow_RegisterClass(void)
2127 /*************************************************************************
2128 * LinkWindow_UnregisterClass (SHELL32.259)
2130 BOOL WINAPI
LinkWindow_UnregisterClass(void)
2136 /*************************************************************************
2137 * SHFlushSFCache (SHELL32.526)
2139 * Notifies the shell that a user-specified special folder location has changed.
2142 * In Wine, the shell folder registry values are not cached, so this function
2145 void WINAPI
SHFlushSFCache(void)
2149 /*************************************************************************
2150 * SHGetImageList (SHELL32.727)
2152 * Returns a copy of a shell image list.
2155 * Windows XP features 4 sizes of image list, and Vista 5. Wine currently
2156 * only supports the traditional small and large image lists, so requests
2157 * for the others will currently fail.
2159 HRESULT WINAPI
SHGetImageList(int iImageList
, REFIID riid
, void **ppv
)
2161 HIMAGELIST hLarge
, hSmall
;
2163 HRESULT ret
= E_FAIL
;
2165 /* Wine currently only maintains large and small image lists */
2166 if ((iImageList
!= SHIL_LARGE
) && (iImageList
!= SHIL_SMALL
) && (iImageList
!= SHIL_SYSSMALL
))
2168 FIXME("Unsupported image list %i requested\n", iImageList
);
2172 Shell_GetImageLists(&hLarge
, &hSmall
);
2173 hNew
= ImageList_Duplicate(iImageList
== SHIL_LARGE
? hLarge
: hSmall
);
2175 /* Get the interface for the new image list */
2178 ret
= HIMAGELIST_QueryInterface(hNew
, riid
, ppv
);
2179 ImageList_Destroy(hNew
);
2185 /*************************************************************************
2186 * SHCreateShellFolderView [SHELL32.256]
2188 * Create a new instance of the default Shell folder view object.
2192 * Failure: error value
2195 * see IShellFolder::CreateViewObject
2197 HRESULT WINAPI
SHCreateShellFolderView(const SFV_CREATE
*pcsfv
,
2203 TRACE("sf=%p outer=%p callback=%p\n",
2204 pcsfv
->pshf
, pcsfv
->psvOuter
, pcsfv
->psfvcb
);
2206 psf
= IShellView_Constructor(pcsfv
->pshf
);
2209 return E_OUTOFMEMORY
;
2211 IShellView_AddRef(psf
);
2212 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppsv
);
2213 IShellView_Release(psf
);