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 "recyclebin.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 * GetFileNameFromBrowse [SHELL32.63]
174 BOOL WINAPI
GetFileNameFromBrowse(
178 LPCWSTR lpstrInitialDir
,
184 FARPROC pGetOpenFileNameW
;
188 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
189 hwndOwner
, debugstr_w(lpstrFile
), nMaxFile
, lpstrInitialDir
, lpstrDefExt
,
190 lpstrFilter
, lpstrTitle
);
192 hmodule
= LoadLibraryW(L
"comdlg32.dll");
193 if(!hmodule
) return FALSE
;
194 pGetOpenFileNameW
= GetProcAddress(hmodule
, "GetOpenFileNameW");
195 if(!pGetOpenFileNameW
)
197 FreeLibrary(hmodule
);
201 memset(&ofn
, 0, sizeof(ofn
));
203 ofn
.lStructSize
= sizeof(ofn
);
204 ofn
.hwndOwner
= hwndOwner
;
205 ofn
.lpstrFilter
= lpstrFilter
;
206 ofn
.lpstrFile
= lpstrFile
;
207 ofn
.nMaxFile
= nMaxFile
;
208 ofn
.lpstrInitialDir
= lpstrInitialDir
;
209 ofn
.lpstrTitle
= lpstrTitle
;
210 ofn
.lpstrDefExt
= lpstrDefExt
;
211 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
212 ret
= pGetOpenFileNameW(&ofn
);
214 FreeLibrary(hmodule
);
218 /*************************************************************************
219 * SHGetSetSettings [SHELL32.68]
221 VOID WINAPI
SHGetSetSettings(LPSHELLSTATE lpss
, DWORD dwMask
, BOOL bSet
)
225 FIXME("%p 0x%08x TRUE\n", lpss
, dwMask
);
229 SHGetSettings((LPSHELLFLAGSTATE
)lpss
,dwMask
);
233 /*************************************************************************
234 * SHGetSettings [SHELL32.@]
237 * the registry path are for win98 (tested)
238 * and possibly are the same in nt40
241 VOID WINAPI
SHGetSettings(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
)
245 DWORD dwDataSize
= sizeof (DWORD
);
247 TRACE("(%p 0x%08x)\n",lpsfs
,dwMask
);
249 if (RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
250 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0))
253 if ( (SSF_SHOWEXTENSIONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideFileExt", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
254 lpsfs
->fShowExtensions
= ((dwData
== 0) ? 0 : 1);
256 if ( (SSF_SHOWINFOTIP
& dwMask
) && !RegQueryValueExA(hKey
, "ShowInfoTip", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
257 lpsfs
->fShowInfoTip
= ((dwData
== 0) ? 0 : 1);
259 if ( (SSF_DONTPRETTYPATH
& dwMask
) && !RegQueryValueExA(hKey
, "DontPrettyPath", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
260 lpsfs
->fDontPrettyPath
= ((dwData
== 0) ? 0 : 1);
262 if ( (SSF_HIDEICONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideIcons", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
263 lpsfs
->fHideIcons
= ((dwData
== 0) ? 0 : 1);
265 if ( (SSF_MAPNETDRVBUTTON
& dwMask
) && !RegQueryValueExA(hKey
, "MapNetDrvBtn", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
266 lpsfs
->fMapNetDrvBtn
= ((dwData
== 0) ? 0 : 1);
268 if ( (SSF_SHOWATTRIBCOL
& dwMask
) && !RegQueryValueExA(hKey
, "ShowAttribCol", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
269 lpsfs
->fShowAttribCol
= ((dwData
== 0) ? 0 : 1);
271 if (((SSF_SHOWALLOBJECTS
| SSF_SHOWSYSFILES
) & dwMask
) && !RegQueryValueExA(hKey
, "Hidden", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
273 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
274 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
276 else if (dwData
== 1)
277 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 1;
278 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
280 else if (dwData
== 2)
281 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
282 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 1;
287 TRACE("-- 0x%04x\n", *(WORD
*)lpsfs
);
290 /*************************************************************************
291 * SHShellFolderView_Message [SHELL32.73]
293 * Send a message to an explorer cabinet window.
296 * hwndCabinet [I] The window containing the shellview to communicate with
297 * dwMessage [I] The SFVM message to send
298 * dwParam [I] Message parameter
304 * Message SFVM_REARRANGE = 1
306 * This message gets sent when a column gets clicked to instruct the
307 * shell view to re-sort the item list. dwParam identifies the column
310 LRESULT WINAPI
SHShellFolderView_Message(
315 FIXME("%p %08x %08lx stub\n",hwndCabinet
, uMessage
, lParam
);
319 /*************************************************************************
320 * RegisterShellHook [SHELL32.181]
322 * Register a shell hook.
325 * hwnd [I] Window handle
326 * dwType [I] Type of hook.
329 * Exported by ordinal
331 BOOL WINAPI
RegisterShellHook(
335 FIXME("(%p,0x%08x):stub.\n",hWnd
, dwType
);
339 /*************************************************************************
340 * ShellMessageBoxW [SHELL32.182]
342 * See ShellMessageBoxA.
345 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
346 * because we can't forward to it in the .spec file since it's exported by
347 * ordinal. If you change the implementation here please update the code in
350 int WINAPIV
ShellMessageBoxW(
358 WCHAR szText
[100],szTitle
[100];
359 LPCWSTR pszText
= szText
, pszTitle
= szTitle
;
364 va_start(args
, uType
);
365 /* wvsprintfA(buf,fmt, args); */
367 TRACE("(%p,%p,%p,%p,%08x)\n",
368 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
370 if (IS_INTRESOURCE(lpCaption
))
371 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]));
373 pszTitle
= lpCaption
;
375 if (IS_INTRESOURCE(lpText
))
376 LoadStringW(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
)/sizeof(szText
[0]));
380 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
381 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
385 ret
= MessageBoxW(hWnd
,pszTemp
,pszTitle
,uType
);
390 /*************************************************************************
391 * ShellMessageBoxA [SHELL32.183]
393 * Format and output an error message.
396 * hInstance [I] Instance handle of message creator
397 * hWnd [I] Window handle of message creator
398 * lpText [I] Resource Id of title or LPSTR
399 * lpCaption [I] Resource Id of title or LPSTR
400 * uType [I] Type of error message
403 * A return value from MessageBoxA().
406 * Exported by ordinal
408 int WINAPIV
ShellMessageBoxA(
416 char szText
[100],szTitle
[100];
417 LPCSTR pszText
= szText
, pszTitle
= szTitle
;
422 va_start(args
, uType
);
423 /* wvsprintfA(buf,fmt, args); */
425 TRACE("(%p,%p,%p,%p,%08x)\n",
426 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
428 if (IS_INTRESOURCE(lpCaption
))
429 LoadStringA(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
));
431 pszTitle
= lpCaption
;
433 if (IS_INTRESOURCE(lpText
))
434 LoadStringA(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
));
438 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
439 pszText
, 0, 0, (LPSTR
)&pszTemp
, 0, &args
);
443 ret
= MessageBoxA(hWnd
,pszTemp
,pszTitle
,uType
);
448 /*************************************************************************
449 * SHRegisterDragDrop [SHELL32.86]
451 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
452 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
453 * for details. Under Windows 98 this function initializes the true OLE when called
454 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
458 * exported by ordinal
461 * RegisterDragDrop, SHLoadOLE
463 HRESULT WINAPI
SHRegisterDragDrop(
465 LPDROPTARGET pDropTarget
)
467 FIXME("(%p,%p):stub.\n", hWnd
, pDropTarget
);
468 return RegisterDragDrop(hWnd
, pDropTarget
);
471 /*************************************************************************
472 * SHRevokeDragDrop [SHELL32.87]
474 * Probably equivalent to RevokeDragDrop but under Windows 9x it could use the
475 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
476 * for details. Function removed from Windows Vista.
479 * exported by ordinal
482 * RevokeDragDrop, SHLoadOLE
484 HRESULT WINAPI
SHRevokeDragDrop(HWND hWnd
)
486 FIXME("(%p):stub.\n",hWnd
);
487 return RevokeDragDrop(hWnd
);
490 /*************************************************************************
491 * SHDoDragDrop [SHELL32.88]
493 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
494 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
498 * exported by ordinal
501 * DoDragDrop, SHLoadOLE
503 HRESULT WINAPI
SHDoDragDrop(
505 LPDATAOBJECT lpDataObject
,
506 LPDROPSOURCE lpDropSource
,
510 FIXME("(%p %p %p 0x%08x %p):stub.\n",
511 hWnd
, lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
512 return DoDragDrop(lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
515 /*************************************************************************
516 * ArrangeWindows [SHELL32.184]
519 WORD WINAPI
ArrangeWindows(
526 /* Unimplemented in WinXP SP3 */
527 TRACE("(%p 0x%08x %p 0x%04x %p):stub.\n",
528 hwndParent
, dwReserved
, lpRect
, cKids
, lpKids
);
532 /*************************************************************************
533 * SignalFileOpen [SHELL32.103]
536 * exported by ordinal
539 SignalFileOpen (LPCITEMIDLIST pidl
)
541 FIXME("(0x%08x):stub.\n", pidl
);
546 /*************************************************************************
547 * SHADD_get_policy - helper function for SHAddToRecentDocs
550 * policy [IN] policy name (null termed string) to find
551 * type [OUT] ptr to DWORD to receive type
552 * buffer [OUT] ptr to area to hold data retrieved
553 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
557 * result of the SHQueryValueEx call
559 static INT
SHADD_get_policy(LPCSTR policy
, LPDWORD type
, LPVOID buffer
, LPDWORD len
)
564 /* Get the key for the policies location in the registry
566 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
567 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
568 0, KEY_READ
, &Policy_basekey
)) {
570 if (RegOpenKeyExA(HKEY_CURRENT_USER
,
571 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
572 0, KEY_READ
, &Policy_basekey
)) {
573 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
576 return ERROR_FILE_NOT_FOUND
;
580 /* Retrieve the data if it exists
582 ret
= SHQueryValueExA(Policy_basekey
, policy
, 0, type
, buffer
, len
);
583 RegCloseKey(Policy_basekey
);
588 /*************************************************************************
589 * SHADD_compare_mru - helper function for SHAddToRecentDocs
592 * data1 [IN] data being looked for
593 * data2 [IN] data in MRU
594 * cbdata [IN] length from FindMRUData call (not used)
597 * position within MRU list that data was added.
599 static INT CALLBACK
SHADD_compare_mru(LPCVOID data1
, LPCVOID data2
, DWORD cbData
)
601 return lstrcmpiA(data1
, data2
);
604 /*************************************************************************
605 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
608 * mruhandle [IN] handle for created MRU list
609 * doc_name [IN] null termed pure doc name
610 * new_lnk_name [IN] null termed path and file name for .lnk file
611 * buffer [IN/OUT] 2048 byte area to construct MRU data
612 * len [OUT] ptr to int to receive space used in buffer
615 * position within MRU list that data was added.
617 static INT
SHADD_create_add_mru_data(HANDLE mruhandle
, LPCSTR doc_name
, LPCSTR new_lnk_name
,
618 LPSTR buffer
, INT
*len
)
624 * RecentDocs MRU data structure seems to be:
625 * +0h document file name w/ terminating 0h
626 * +nh short int w/ size of remaining
627 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
628 * +n+4h 10 bytes zeros - unknown
629 * +n+eh shortcut file name w/ terminating 0h
630 * +n+e+nh 3 zero bytes - unknown
633 /* Create the MRU data structure for "RecentDocs"
636 lstrcpyA(ptr
, doc_name
);
637 ptr
+= (lstrlenA(buffer
) + 1);
638 wlen
= lstrlenA(new_lnk_name
) + 1 + 12;
639 *((short int*)ptr
) = wlen
;
640 ptr
+= 2; /* step past the length */
641 *(ptr
++) = 0x30; /* unknown reason */
642 *(ptr
++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
645 lstrcpyA(ptr
, new_lnk_name
);
646 ptr
+= (lstrlenA(new_lnk_name
) + 1);
651 /* Add the new entry into the MRU list
653 return AddMRUData(mruhandle
, buffer
, *len
);
656 /*************************************************************************
657 * SHAddToRecentDocs [SHELL32.@]
659 * Modify (add/clear) Shell's list of recently used documents.
662 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
663 * pv [IN] string or pidl, NULL clears the list
671 void WINAPI
SHAddToRecentDocs (UINT uFlags
,LPCVOID pv
)
673 /* If list is a string list lpfnCompare has the following prototype
674 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
675 * for binary lists the prototype is
676 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
677 * where cbData is the no. of bytes to compare.
678 * Need to check what return value means identical - 0?
684 CHAR doc_name
[MAX_PATH
];
685 CHAR link_dir
[MAX_PATH
];
686 CHAR new_lnk_filepath
[MAX_PATH
];
687 CHAR new_lnk_name
[MAX_PATH
];
690 HWND hwnd
= 0; /* FIXME: get real window handle */
692 DWORD data
[64], datalen
, type
;
694 TRACE("%04x %p\n", uFlags
, pv
);
697 * RecentDocs MRU data structure seems to be:
698 * +0h document file name w/ terminating 0h
699 * +nh short int w/ size of remaining
700 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
701 * +n+4h 10 bytes zeros - unknown
702 * +n+eh shortcut file name w/ terminating 0h
703 * +n+e+nh 3 zero bytes - unknown
706 /* See if we need to do anything.
709 ret
=SHADD_get_policy( "NoRecentDocsHistory", &type
, data
, &datalen
);
710 if ((ret
> 0) && (ret
!= ERROR_FILE_NOT_FOUND
)) {
711 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret
);
714 if (ret
== ERROR_SUCCESS
) {
715 if (!( (type
== REG_DWORD
) ||
716 ((type
== REG_BINARY
) && (datalen
== 4)) )) {
717 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
722 TRACE("policy value for NoRecentDocsHistory = %08x\n", data
[0]);
723 /* now test the actual policy value */
728 /* Open key to where the necessary info is
730 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
731 * and the close should be done during the _DETACH. The resulting
732 * key is stored in the DLL global data.
734 if (RegCreateKeyExA(HKEY_CURRENT_USER
,
735 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
736 0, 0, 0, KEY_READ
, 0, &HCUbasekey
, 0)) {
737 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
741 /* Get path to user's "Recent" directory
743 if(SUCCEEDED(SHGetMalloc(&ppM
))) {
744 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd
, CSIDL_RECENT
,
746 SHGetPathFromIDListA(pidl
, link_dir
);
747 IMalloc_Free(ppM
, pidl
);
752 ERR("serious issues 1\n");
754 IMalloc_Release(ppM
);
759 ERR("serious issues 2\n");
761 TRACE("Users Recent dir %s\n", link_dir
);
763 /* If no input, then go clear the lists */
765 /* clear user's Recent dir
768 /* FIXME: delete all files in "link_dir"
770 * while( more files ) {
771 * lstrcpyA(old_lnk_name, link_dir);
772 * PathAppendA(old_lnk_name, filenam);
773 * DeleteFileA(old_lnk_name);
776 FIXME("should delete all files in %s\\\n", link_dir
);
780 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
781 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
782 * and naturally it fails w/ rc=2. It should do it against
783 * HKEY_CURRENT_USER which is where it is stored, and where
784 * the MRU routines expect it!!!!
786 RegDeleteKeyA(HCUbasekey
, "RecentDocs");
787 RegCloseKey(HCUbasekey
);
791 /* Have data to add, the jobs to be done:
792 * 1. Add document to MRU list in registry "HKCU\Software\
793 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
794 * 2. Add shortcut to document in the user's Recent directory
796 * 3. Add shortcut to Start menu's Documents submenu.
799 /* Get the pure document name from the input
804 SHGetPathFromIDListA(pv
, doc_name
);
808 lstrcpynA(doc_name
, pv
, MAX_PATH
);
812 WideCharToMultiByte(CP_ACP
, 0, pv
, -1, doc_name
, MAX_PATH
, NULL
, NULL
);
816 FIXME("Unsupported flags: %u\n", uFlags
);
820 TRACE("full document name %s\n", debugstr_a(doc_name
));
821 PathStripPathA(doc_name
);
822 TRACE("stripped document name %s\n", debugstr_a(doc_name
));
825 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
828 * doc_name - pure file-spec, no path
829 * link_dir - path to the user's Recent directory
830 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
832 * new_lnk_name- pure file-spec, no path for new .lnk file
834 * - path and file name of new .lnk file
836 CREATEMRULISTA mymru
;
838 INT len
, pos
, bufused
, err
;
843 CHAR old_lnk_name
[MAX_PATH
];
846 mymru
.cbSize
= sizeof(CREATEMRULISTA
);
847 mymru
.nMaxItems
= 15;
848 mymru
.dwFlags
= MRUF_BINARY_LIST
| MRUF_DELAYED_SAVE
;
849 mymru
.hKey
= HCUbasekey
;
850 mymru
.lpszSubKey
= "RecentDocs";
851 mymru
.lpfnCompare
= (PROC
)SHADD_compare_mru
;
852 mruhandle
= CreateMRUListA(&mymru
);
855 ERR("MRU processing failed, handle zero\n");
856 RegCloseKey(HCUbasekey
);
859 len
= lstrlenA(doc_name
);
860 pos
= FindMRUData(mruhandle
, doc_name
, len
, 0);
862 /* Now get the MRU entry that will be replaced
863 * and delete the .lnk file for it
865 if ((bufused
= EnumMRUListA(mruhandle
, (pos
== -1) ? 14 : pos
,
866 buffer
, 2048)) != -1) {
868 ptr
+= (lstrlenA(buffer
) + 1);
869 slen
= *((short int*)ptr
);
870 ptr
+= 2; /* skip the length area */
871 if (bufused
>= slen
+ (ptr
-buffer
)) {
872 /* buffer size looks good */
873 ptr
+= 12; /* get to string */
874 len
= bufused
- (ptr
-buffer
); /* get length of buf remaining */
875 if ((lstrlenA(ptr
) > 0) && (lstrlenA(ptr
) <= len
-1)) {
876 /* appears to be good string */
877 lstrcpyA(old_lnk_name
, link_dir
);
878 PathAppendA(old_lnk_name
, ptr
);
879 if (!DeleteFileA(old_lnk_name
)) {
880 if ((attr
= GetFileAttributesA(old_lnk_name
)) == INVALID_FILE_ATTRIBUTES
) {
881 if ((err
= GetLastError()) != ERROR_FILE_NOT_FOUND
) {
882 ERR("Delete for %s failed, err=%d, attr=%08x\n",
883 old_lnk_name
, err
, attr
);
886 TRACE("old .lnk file %s did not exist\n",
891 ERR("Delete for %s failed, attr=%08x\n",
896 TRACE("deleted old .lnk file %s\n", old_lnk_name
);
902 /* Create usable .lnk file name for the "Recent" directory
904 wsprintfA(new_lnk_name
, "%s.lnk", doc_name
);
905 lstrcpyA(new_lnk_filepath
, link_dir
);
906 PathAppendA(new_lnk_filepath
, new_lnk_name
);
908 olderrormode
= SetErrorMode(SEM_FAILCRITICALERRORS
);
909 while (GetFileAttributesA(new_lnk_filepath
) != INVALID_FILE_ATTRIBUTES
) {
911 wsprintfA(new_lnk_name
, "%s (%u).lnk", doc_name
, i
);
912 lstrcpyA(new_lnk_filepath
, link_dir
);
913 PathAppendA(new_lnk_filepath
, new_lnk_name
);
915 SetErrorMode(olderrormode
);
916 TRACE("new shortcut will be %s\n", new_lnk_filepath
);
918 /* Now add the new MRU entry and data
920 pos
= SHADD_create_add_mru_data(mruhandle
, doc_name
, new_lnk_name
,
922 FreeMRUList(mruhandle
);
923 TRACE("Updated MRU list, new doc is position %d\n", pos
);
926 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
929 * doc_name - pure file-spec, no path
931 * - path and file name of new .lnk file
932 * uFlags[in] - flags on call to SHAddToRecentDocs
933 * pv[in] - document path/pidl on call to SHAddToRecentDocs
935 IShellLinkA
*psl
= NULL
;
936 IPersistFile
*pPf
= NULL
;
939 WCHAR widelink
[MAX_PATH
];
943 hres
= CoCreateInstance( &CLSID_ShellLink
,
945 CLSCTX_INPROC_SERVER
,
948 if(SUCCEEDED(hres
)) {
950 hres
= IShellLinkA_QueryInterface(psl
, &IID_IPersistFile
,
954 ERR("failed QueryInterface for IPersistFile %08x\n", hres
);
958 /* Set the document path or pidl */
959 if (uFlags
== SHARD_PIDL
) {
960 hres
= IShellLinkA_SetIDList(psl
, pv
);
962 hres
= IShellLinkA_SetPath(psl
, pv
);
966 ERR("failed Set{IDList|Path} %08x\n", hres
);
970 lstrcpyA(desc
, "Shortcut to ");
971 lstrcatA(desc
, doc_name
);
972 hres
= IShellLinkA_SetDescription(psl
, desc
);
975 ERR("failed SetDescription %08x\n", hres
);
979 MultiByteToWideChar(CP_ACP
, 0, new_lnk_filepath
, -1,
981 /* create the short cut */
982 hres
= IPersistFile_Save(pPf
, widelink
, TRUE
);
985 ERR("failed IPersistFile::Save %08x\n", hres
);
986 IPersistFile_Release(pPf
);
987 IShellLinkA_Release(psl
);
990 hres
= IPersistFile_SaveCompleted(pPf
, widelink
);
991 IPersistFile_Release(pPf
);
992 IShellLinkA_Release(psl
);
993 TRACE("shortcut %s has been created, result=%08x\n",
994 new_lnk_filepath
, hres
);
997 ERR("CoCreateInstance failed, hres=%08x\n", hres
);
1005 RegCloseKey(HCUbasekey
);
1009 /*************************************************************************
1010 * SHCreateShellFolderViewEx [SHELL32.174]
1012 * Create a new instance of the default Shell folder view object.
1016 * Failure: error value
1019 * see IShellFolder::CreateViewObject
1021 HRESULT WINAPI
SHCreateShellFolderViewEx(
1022 LPCSFV psvcbi
, /* [in] shelltemplate struct */
1023 IShellView
**ppv
) /* [out] IShellView pointer */
1028 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1029 psvcbi
->pshf
, psvcbi
->pidl
, psvcbi
->pfnCallback
,
1030 psvcbi
->fvm
, psvcbi
->psvOuter
);
1032 psf
= IShellView_Constructor(psvcbi
->pshf
);
1035 return E_OUTOFMEMORY
;
1037 IShellView_AddRef(psf
);
1038 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppv
);
1039 IShellView_Release(psf
);
1043 /*************************************************************************
1044 * SHWinHelp [SHELL32.127]
1047 HRESULT WINAPI
SHWinHelp (DWORD v
, DWORD w
, DWORD x
, DWORD z
)
1048 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v
,w
,x
,z
);
1051 /*************************************************************************
1052 * SHRunControlPanel [SHELL32.161]
1055 HRESULT WINAPI
SHRunControlPanel (LPCWSTR lpcszCmdLine
, HWND hwndMsgParent
)
1057 FIXME("0x%08x 0x%08x stub\n",lpcszCmdLine
,hwndMsgParent
);
1061 static LPUNKNOWN SHELL32_IExplorerInterface
=0;
1062 /*************************************************************************
1063 * SHSetInstanceExplorer [SHELL32.176]
1066 * Sets the interface
1068 VOID WINAPI
SHSetInstanceExplorer (LPUNKNOWN lpUnknown
)
1069 { TRACE("%p\n", lpUnknown
);
1070 SHELL32_IExplorerInterface
= lpUnknown
;
1072 /*************************************************************************
1073 * SHGetInstanceExplorer [SHELL32.@]
1076 * gets the interface pointer of the explorer and a reference
1078 HRESULT WINAPI
SHGetInstanceExplorer (IUnknown
**lpUnknown
)
1079 { TRACE("%p\n", lpUnknown
);
1081 *lpUnknown
= SHELL32_IExplorerInterface
;
1083 if (!SHELL32_IExplorerInterface
)
1086 IUnknown_AddRef(SHELL32_IExplorerInterface
);
1089 /*************************************************************************
1090 * SHFreeUnusedLibraries [SHELL32.123]
1092 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1093 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1097 * exported by ordinal
1100 * CoFreeUnusedLibraries, SHLoadOLE
1102 void WINAPI
SHFreeUnusedLibraries (void)
1105 CoFreeUnusedLibraries();
1107 /*************************************************************************
1108 * DAD_AutoScroll [SHELL32.129]
1111 BOOL WINAPI
DAD_AutoScroll(HWND hwnd
, AUTO_SCROLL_DATA
*samples
, const POINT
* pt
)
1113 FIXME("hwnd = %p %p %p\n",hwnd
,samples
,pt
);
1116 /*************************************************************************
1117 * DAD_DragEnter [SHELL32.130]
1120 BOOL WINAPI
DAD_DragEnter(HWND hwnd
)
1122 FIXME("hwnd = %p\n",hwnd
);
1125 /*************************************************************************
1126 * DAD_DragEnterEx [SHELL32.131]
1129 BOOL WINAPI
DAD_DragEnterEx(HWND hwnd
, POINT p
)
1131 FIXME("hwnd = %p (%d,%d)\n",hwnd
,p
.x
,p
.y
);
1134 /*************************************************************************
1135 * DAD_DragMove [SHELL32.134]
1138 BOOL WINAPI
DAD_DragMove(POINT p
)
1140 FIXME("(%d,%d)\n",p
.x
,p
.y
);
1143 /*************************************************************************
1144 * DAD_DragLeave [SHELL32.132]
1147 BOOL WINAPI
DAD_DragLeave(VOID
)
1152 /*************************************************************************
1153 * DAD_SetDragImage [SHELL32.136]
1158 BOOL WINAPI
DAD_SetDragImage(
1159 HIMAGELIST himlTrack
,
1162 FIXME("%p %p stub\n",himlTrack
, lppt
);
1165 /*************************************************************************
1166 * DAD_ShowDragImage [SHELL32.137]
1171 BOOL WINAPI
DAD_ShowDragImage(BOOL bShow
)
1173 FIXME("0x%08x stub\n",bShow
);
1177 static const WCHAR szwCabLocation
[] = {
1178 'S','o','f','t','w','a','r','e','\\',
1179 'M','i','c','r','o','s','o','f','t','\\',
1180 'W','i','n','d','o','w','s','\\',
1181 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1182 'E','x','p','l','o','r','e','r','\\',
1183 'C','a','b','i','n','e','t','S','t','a','t','e',0
1186 static const WCHAR szwSettings
[] = { 'S','e','t','t','i','n','g','s',0 };
1188 /*************************************************************************
1189 * ReadCabinetState [SHELL32.651] NT 4.0
1192 BOOL WINAPI
ReadCabinetState(CABINETSTATE
*cs
, int length
)
1197 TRACE("%p %d\n", cs
, length
);
1199 if( (cs
== NULL
) || (length
< (int)sizeof(*cs
)) )
1202 r
= RegOpenKeyW( HKEY_CURRENT_USER
, szwCabLocation
, &hkey
);
1203 if( r
== ERROR_SUCCESS
)
1206 r
= RegQueryValueExW( hkey
, szwSettings
,
1207 NULL
, &type
, (LPBYTE
)cs
, (LPDWORD
)&length
);
1208 RegCloseKey( hkey
);
1212 /* if we can't read from the registry, create default values */
1213 if ( (r
!= ERROR_SUCCESS
) || (cs
->cLength
< sizeof(*cs
)) ||
1214 (cs
->cLength
!= length
) )
1216 ERR("Initializing shell cabinet settings\n");
1217 memset(cs
, 0, sizeof(*cs
));
1218 cs
->cLength
= sizeof(*cs
);
1220 cs
->fFullPathTitle
= FALSE
;
1221 cs
->fSaveLocalView
= TRUE
;
1222 cs
->fNotShell
= FALSE
;
1223 cs
->fSimpleDefault
= TRUE
;
1224 cs
->fDontShowDescBar
= FALSE
;
1225 cs
->fNewWindowMode
= FALSE
;
1226 cs
->fShowCompColor
= FALSE
;
1227 cs
->fDontPrettyNames
= FALSE
;
1228 cs
->fAdminsCreateCommonGroups
= TRUE
;
1229 cs
->fMenuEnumFilter
= 96;
1235 /*************************************************************************
1236 * WriteCabinetState [SHELL32.652] NT 4.0
1239 BOOL WINAPI
WriteCabinetState(CABINETSTATE
*cs
)
1249 r
= RegCreateKeyExW( HKEY_CURRENT_USER
, szwCabLocation
, 0,
1250 NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
1251 if( r
== ERROR_SUCCESS
)
1253 r
= RegSetValueExW( hkey
, szwSettings
, 0,
1254 REG_BINARY
, (LPBYTE
) cs
, cs
->cLength
);
1256 RegCloseKey( hkey
);
1259 return (r
==ERROR_SUCCESS
);
1262 /*************************************************************************
1263 * FileIconInit [SHELL32.660]
1266 BOOL WINAPI
FileIconInit(BOOL bFullInit
)
1267 { FIXME("(%s)\n", bFullInit
? "true" : "false");
1271 /*************************************************************************
1272 * IsUserAnAdmin [SHELL32.680] NT 4.0
1274 * Checks whether the current user is a member of the Administrators group.
1283 BOOL WINAPI
IsUserAnAdmin(VOID
)
1285 SID_IDENTIFIER_AUTHORITY Authority
= {SECURITY_NT_AUTHORITY
};
1288 PTOKEN_GROUPS lpGroups
;
1291 BOOL bResult
= FALSE
;
1294 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &hToken
))
1299 if (!GetTokenInformation(hToken
, TokenGroups
, NULL
, 0, &dwSize
))
1301 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
1303 CloseHandle(hToken
);
1308 lpGroups
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
1309 if (lpGroups
== NULL
)
1311 CloseHandle(hToken
);
1315 if (!GetTokenInformation(hToken
, TokenGroups
, lpGroups
, dwSize
, &dwSize
))
1317 HeapFree(GetProcessHeap(), 0, lpGroups
);
1318 CloseHandle(hToken
);
1322 CloseHandle(hToken
);
1324 if (!AllocateAndInitializeSid(&Authority
, 2, SECURITY_BUILTIN_DOMAIN_RID
,
1325 DOMAIN_ALIAS_RID_ADMINS
, 0, 0, 0, 0, 0, 0,
1328 HeapFree(GetProcessHeap(), 0, lpGroups
);
1332 for (i
= 0; i
< lpGroups
->GroupCount
; i
++)
1334 if (EqualSid(lpSid
, lpGroups
->Groups
[i
].Sid
))
1342 HeapFree(GetProcessHeap(), 0, lpGroups
);
1346 /*************************************************************************
1347 * SHAllocShared [SHELL32.520]
1349 * See shlwapi.SHAllocShared
1351 HANDLE WINAPI
SHAllocShared(LPVOID lpvData
, DWORD dwSize
, DWORD dwProcId
)
1353 GET_FUNC(pSHAllocShared
, shlwapi
, (char*)7, NULL
);
1354 return pSHAllocShared(lpvData
, dwSize
, dwProcId
);
1357 /*************************************************************************
1358 * SHLockShared [SHELL32.521]
1360 * See shlwapi.SHLockShared
1362 LPVOID WINAPI
SHLockShared(HANDLE hShared
, DWORD dwProcId
)
1364 GET_FUNC(pSHLockShared
, shlwapi
, (char*)8, NULL
);
1365 return pSHLockShared(hShared
, dwProcId
);
1368 /*************************************************************************
1369 * SHUnlockShared [SHELL32.522]
1371 * See shlwapi.SHUnlockShared
1373 BOOL WINAPI
SHUnlockShared(LPVOID lpView
)
1375 GET_FUNC(pSHUnlockShared
, shlwapi
, (char*)9, FALSE
);
1376 return pSHUnlockShared(lpView
);
1379 /*************************************************************************
1380 * SHFreeShared [SHELL32.523]
1382 * See shlwapi.SHFreeShared
1384 BOOL WINAPI
SHFreeShared(HANDLE hShared
, DWORD dwProcId
)
1386 GET_FUNC(pSHFreeShared
, shlwapi
, (char*)10, FALSE
);
1387 return pSHFreeShared(hShared
, dwProcId
);
1390 /*************************************************************************
1391 * SetAppStartingCursor [SHELL32.99]
1393 HRESULT WINAPI
SetAppStartingCursor(HWND u
, DWORD v
)
1394 { FIXME("hwnd=%p 0x%04x stub\n",u
,v
);
1398 /*************************************************************************
1399 * SHLoadOLE [SHELL32.151]
1401 * To reduce the memory usage of Windows 95, its shell32 contained an
1402 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1403 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1404 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1405 * would just call the Co* functions.
1407 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1408 * information from the shell32 "mini-COM" to ole32.dll.
1410 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1411 * detailed description.
1413 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1414 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1415 * hack in SHCoCreateInstance)
1417 HRESULT WINAPI
SHLoadOLE(LPARAM lParam
)
1418 { FIXME("0x%08lx stub\n",lParam
);
1421 /*************************************************************************
1422 * DriveType [SHELL32.64]
1425 HRESULT WINAPI
DriveType(int DriveType
)
1427 WCHAR root
[] = L
"A:\\";
1428 root
[0] = L
'A' + DriveType
;
1429 return GetDriveTypeW(root
);
1431 /*************************************************************************
1432 * InvalidateDriveType [SHELL32.65]
1433 * Unimplemented in XP SP3
1435 int WINAPI
InvalidateDriveType(int u
)
1437 TRACE("0x%08x stub\n",u
);
1440 /*************************************************************************
1441 * SHAbortInvokeCommand [SHELL32.198]
1444 HRESULT WINAPI
SHAbortInvokeCommand(void)
1448 /*************************************************************************
1449 * SHOutOfMemoryMessageBox [SHELL32.126]
1452 int WINAPI
SHOutOfMemoryMessageBox(
1457 FIXME("%p %s 0x%08x stub\n",hwndOwner
, lpCaption
, uType
);
1460 /*************************************************************************
1461 * SHFlushClipboard [SHELL32.121]
1464 HRESULT WINAPI
SHFlushClipboard(void)
1466 return OleFlushClipboard();
1469 /*************************************************************************
1470 * SHWaitForFileToOpen [SHELL32.97]
1473 BOOL WINAPI
SHWaitForFileToOpen(
1478 FIXME("%p 0x%08x 0x%08x stub\n", pidl
, dwFlags
, dwTimeout
);
1482 /************************************************************************
1483 * RLBuildListOfPaths [SHELL32.146]
1488 DWORD WINAPI
RLBuildListOfPaths (void)
1492 /************************************************************************
1493 * SHValidateUNC [SHELL32.173]
1496 HRESULT WINAPI
SHValidateUNC (HWND hwndOwner
, LPWSTR pszFile
, UINT fConnect
)
1498 FIXME("0x%08x 0x%08x 0x%08x stub\n",hwndOwner
,pszFile
,fConnect
);
1502 /************************************************************************
1503 * DoEnvironmentSubstA [SHELL32.@]
1505 * Replace %KEYWORD% in the str with the value of variable KEYWORD
1506 * from environment. If it is not found the %KEYWORD% is left
1507 * intact. If the buffer is too small, str is not modified.
1510 * pszString [I] '\0' terminated string with %keyword%.
1511 * [O] '\0' terminated string with %keyword% substituted.
1512 * cchString [I] size of str.
1515 * cchString length in the HIWORD;
1516 * TRUE in LOWORD if subst was successful and FALSE in other case
1518 DWORD WINAPI
DoEnvironmentSubstA(LPSTR pszString
, UINT cchString
)
1522 FIXME("(%s, %d) stub\n", debugstr_a(pszString
), cchString
);
1523 if (pszString
== NULL
) /* Really return 0? */
1525 if ((dst
= HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(CHAR
))))
1527 DWORD num
= ExpandEnvironmentStringsA(pszString
, dst
, cchString
);
1528 if (num
&& num
< cchString
) /* dest buffer is too small */
1531 memcpy(pszString
, dst
, num
);
1533 HeapFree(GetProcessHeap(), 0, dst
);
1535 return MAKELONG(res
,cchString
); /* Always cchString? */
1538 /************************************************************************
1539 * DoEnvironmentSubstW [SHELL32.@]
1541 * See DoEnvironmentSubstA.
1543 DWORD WINAPI
DoEnvironmentSubstW(LPWSTR pszString
, UINT cchString
)
1547 FIXME("(%s, %d): stub\n", debugstr_w(pszString
), cchString
);
1548 if ((dst
= HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(WCHAR
))))
1550 DWORD num
= ExpandEnvironmentStringsW(pszString
, dst
, cchString
);
1554 wcscpy(pszString
, dst
);
1556 HeapFree(GetProcessHeap(), 0, dst
);
1559 return MAKELONG(res
,cchString
);
1562 /************************************************************************
1563 * DoEnvironmentSubst [SHELL32.53]
1565 * See DoEnvironmentSubstA.
1567 DWORD WINAPI
DoEnvironmentSubstAW(LPVOID x
, UINT y
)
1569 if (SHELL_OsIsUnicode())
1570 return DoEnvironmentSubstW(x
, y
);
1571 return DoEnvironmentSubstA(x
, y
);
1574 /*************************************************************************
1575 * GUIDFromStringA [SHELL32.703]
1577 BOOL WINAPI
GUIDFromStringA(LPCSTR str
, LPGUID guid
)
1579 TRACE("GUIDFromStringA() stub\n");
1583 /*************************************************************************
1584 * GUIDFromStringW [SHELL32.704]
1586 BOOL WINAPI
GUIDFromStringW(LPCWSTR str
, LPGUID guid
)
1588 UNICODE_STRING guid_str
;
1590 RtlInitUnicodeString(&guid_str
, str
);
1591 return !RtlGUIDFromString(&guid_str
, guid
);
1594 /*************************************************************************
1595 * PathIsTemporaryW [SHELL32.714]
1597 BOOL WINAPI
PathIsTemporaryW(LPWSTR Str
)
1599 FIXME("(%s)stub\n", debugstr_w(Str
));
1603 /*************************************************************************
1604 * PathIsTemporaryA [SHELL32.713]
1606 BOOL WINAPI
PathIsTemporaryA(LPSTR Str
)
1608 FIXME("(%s)stub\n", debugstr_a(Str
));
1612 typedef struct _PSXA
1616 IShellPropSheetExt
*pspsx
[1];
1619 typedef struct _PSXA_CALL
1621 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith
;
1626 } PSXA_CALL
, *PPSXA_CALL
;
1628 static BOOL CALLBACK
PsxaCall(HPROPSHEETPAGE hpage
, LPARAM lParam
)
1630 PPSXA_CALL Call
= (PPSXA_CALL
)lParam
;
1634 if ((Call
->bMultiple
|| !Call
->bCalled
) &&
1635 Call
->lpfnAddReplaceWith(hpage
, Call
->lParam
))
1637 Call
->bCalled
= TRUE
;
1646 /*************************************************************************
1647 * SHAddFromPropSheetExtArray [SHELL32.167]
1649 UINT WINAPI
SHAddFromPropSheetExtArray(HPSXA hpsxa
, LPFNADDPROPSHEETPAGE lpfnAddPage
, LPARAM lParam
)
1653 PPSXA psxa
= (PPSXA
)hpsxa
;
1655 TRACE("(%p,%p,%08lx)\n", hpsxa
, lpfnAddPage
, lParam
);
1659 ZeroMemory(&Call
, sizeof(Call
));
1660 Call
.lpfnAddReplaceWith
= lpfnAddPage
;
1661 Call
.lParam
= lParam
;
1662 Call
.bMultiple
= TRUE
;
1664 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1665 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1667 psxa
->pspsx
[i
]->lpVtbl
->AddPages(psxa
->pspsx
[i
], PsxaCall
, (LPARAM
)&Call
);
1670 return Call
.uiCount
;
1676 /*************************************************************************
1677 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1679 HPSXA WINAPI
SHCreatePropSheetExtArrayEx(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
, IDataObject
*pDataObj
)
1681 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};
1682 WCHAR szHandler
[64];
1684 WCHAR szClsidHandler
[39];
1689 IShellExtInit
*psxi
;
1690 IShellPropSheetExt
*pspsx
;
1691 HKEY hkBase
, hkPropSheetHandlers
;
1695 TRACE("(%p,%s,%u)\n", hKey
, debugstr_w(pszSubKey
), max_iface
);
1700 /* Open the registry key */
1701 lRet
= RegOpenKeyW(hKey
, pszSubKey
, &hkBase
);
1702 if (lRet
!= ERROR_SUCCESS
)
1705 lRet
= RegOpenKeyExW(hkBase
, szPropSheetSubKey
, 0, KEY_ENUMERATE_SUB_KEYS
, &hkPropSheetHandlers
);
1706 RegCloseKey(hkBase
);
1707 if (lRet
== ERROR_SUCCESS
)
1709 /* Create and initialize the Property Sheet Extensions Array */
1710 psxa
= LocalAlloc(LMEM_FIXED
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1713 ZeroMemory(psxa
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1714 psxa
->uiAllocated
= max_iface
;
1716 /* Enumerate all subkeys and attempt to load the shell extensions */
1720 dwHandlerLen
= sizeof(szHandler
) / sizeof(szHandler
[0]);
1721 lRet
= RegEnumKeyExW(hkPropSheetHandlers
, dwIndex
++, szHandler
, &dwHandlerLen
, NULL
, NULL
, NULL
, NULL
);
1722 if (lRet
!= ERROR_SUCCESS
)
1724 if (lRet
== ERROR_MORE_DATA
)
1727 if (lRet
== ERROR_NO_MORE_ITEMS
)
1728 lRet
= ERROR_SUCCESS
;
1731 szHandler
[(sizeof(szHandler
) / sizeof(szHandler
[0])) - 1] = 0;
1732 hr
= CLSIDFromString(szHandler
, &clsid
);
1735 dwClsidSize
= sizeof(szClsidHandler
);
1736 if (SHGetValueW(hkPropSheetHandlers
, szHandler
, NULL
, NULL
, szClsidHandler
, &dwClsidSize
) == ERROR_SUCCESS
)
1738 szClsidHandler
[(sizeof(szClsidHandler
) / sizeof(szClsidHandler
[0])) - 1] = 0;
1739 hr
= CLSIDFromString(szClsidHandler
, &clsid
);
1744 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1745 Only if both interfaces are supported it's a real shell extension.
1746 Then call IShellExtInit's Initialize method. */
1747 if (SUCCEEDED(CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt
, (LPVOID
*)&pspsx
)))
1749 if (SUCCEEDED(pspsx
->lpVtbl
->QueryInterface(pspsx
, &IID_IShellExtInit
, (PVOID
*)&psxi
)))
1751 if (SUCCEEDED(psxi
->lpVtbl
->Initialize(psxi
, NULL
, pDataObj
, hKey
)))
1753 /* Add the IShellPropSheetExt instance to the array */
1754 psxa
->pspsx
[psxa
->uiCount
++] = pspsx
;
1758 psxi
->lpVtbl
->Release(psxi
);
1759 pspsx
->lpVtbl
->Release(pspsx
);
1763 pspsx
->lpVtbl
->Release(pspsx
);
1766 } while (psxa
->uiCount
!= psxa
->uiAllocated
);
1769 lRet
= ERROR_NOT_ENOUGH_MEMORY
;
1771 RegCloseKey(hkPropSheetHandlers
);
1774 if (lRet
!= ERROR_SUCCESS
&& psxa
)
1776 SHDestroyPropSheetExtArray((HPSXA
)psxa
);
1783 /*************************************************************************
1784 * SHCreatePropSheetExtArray [SHELL32.168]
1786 HPSXA WINAPI
SHCreatePropSheetExtArray(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
)
1788 return SHCreatePropSheetExtArrayEx(hKey
, pszSubKey
, max_iface
, NULL
);
1792 /*************************************************************************
1793 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1795 UINT WINAPI
SHReplaceFromPropSheetExtArray(HPSXA hpsxa
, UINT uPageID
, LPFNADDPROPSHEETPAGE lpfnReplaceWith
, LPARAM lParam
)
1799 PPSXA psxa
= (PPSXA
)hpsxa
;
1801 TRACE("(%p,%u,%p,%08lx)\n", hpsxa
, uPageID
, lpfnReplaceWith
, lParam
);
1805 ZeroMemory(&Call
, sizeof(Call
));
1806 Call
.lpfnAddReplaceWith
= lpfnReplaceWith
;
1807 Call
.lParam
= lParam
;
1809 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1810 Each shell extension is only allowed to call the callback once during the callback. */
1811 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1813 Call
.bCalled
= FALSE
;
1814 psxa
->pspsx
[i
]->lpVtbl
->ReplacePage(psxa
->pspsx
[i
], uPageID
, PsxaCall
, (LPARAM
)&Call
);
1817 return Call
.uiCount
;
1823 /*************************************************************************
1824 * SHDestroyPropSheetExtArray [SHELL32.169]
1826 void WINAPI
SHDestroyPropSheetExtArray(HPSXA hpsxa
)
1829 PPSXA psxa
= (PPSXA
)hpsxa
;
1831 TRACE("(%p)\n", hpsxa
);
1835 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1837 psxa
->pspsx
[i
]->lpVtbl
->Release(psxa
->pspsx
[i
]);
1844 /*************************************************************************
1845 * CIDLData_CreateFromIDArray [SHELL32.83]
1847 * Create IDataObject from PIDLs??
1849 HRESULT WINAPI
CIDLData_CreateFromIDArray(
1850 LPCITEMIDLIST pidlFolder
,
1852 LPCITEMIDLIST
*lppidlFiles
,
1853 IDataObject
**ppdataObject
)
1856 HWND hwnd
= 0; /*FIXME: who should be hwnd of owner? set to desktop */
1858 TRACE("(%p, %d, %p, %p)\n", pidlFolder
, cpidlFiles
, lppidlFiles
, ppdataObject
);
1862 for (i
=0; i
<cpidlFiles
; i
++) pdump (lppidlFiles
[i
]);
1864 *ppdataObject
= IDataObject_Constructor( hwnd
, pidlFolder
,
1865 lppidlFiles
, cpidlFiles
);
1866 if (*ppdataObject
) return S_OK
;
1867 return E_OUTOFMEMORY
;
1870 /*************************************************************************
1871 * SHCreateStdEnumFmtEtc [SHELL32.74]
1876 HRESULT WINAPI
SHCreateStdEnumFmtEtc(
1878 const FORMATETC
*lpFormats
,
1879 LPENUMFORMATETC
*ppenumFormatetc
)
1881 IEnumFORMATETC
*pef
;
1883 TRACE("cf=%d fe=%p pef=%p\n", cFormats
, lpFormats
, ppenumFormatetc
);
1885 pef
= IEnumFORMATETC_Constructor(cFormats
, lpFormats
);
1887 return E_OUTOFMEMORY
;
1889 IEnumFORMATETC_AddRef(pef
);
1890 hRes
= IEnumFORMATETC_QueryInterface(pef
, &IID_IEnumFORMATETC
, (LPVOID
*)ppenumFormatetc
);
1891 IEnumFORMATETC_Release(pef
);
1897 /*************************************************************************
1898 * SHCreateShellFolderView (SHELL32.256)
1900 HRESULT WINAPI
SHCreateShellFolderView(const SFV_CREATE
*pcsfv
, IShellView
**ppsv
)
1904 FIXME("SHCreateShellFolderView() stub\n");
1906 if (!pcsfv
|| sizeof(*pcsfv
) != pcsfv
->cbSize
)
1910 LPVOID lpdata
= 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1913 ret
= E_OUTOFMEMORY
;
1916 /* Initialize and return unknown lpdata structure */
1923 /*************************************************************************
1924 * SHFindFiles (SHELL32.90)
1926 BOOL WINAPI
SHFindFiles( LPCITEMIDLIST pidlFolder
, LPCITEMIDLIST pidlSaveFile
)
1928 FIXME("%p %p\n", pidlFolder
, pidlSaveFile
);
1932 /*************************************************************************
1933 * SHUpdateImageW (SHELL32.192)
1935 * Notifies the shell that an icon in the system image list has been changed.
1938 * pszHashItem [I] Path to file that contains the icon.
1939 * iIndex [I] Zero-based index of the icon in the file.
1940 * uFlags [I] Flags determining the icon attributes. See notes.
1941 * iImageIndex [I] Index of the icon in the system image list.
1947 * uFlags can be one or more of the following flags:
1948 * GIL_NOTFILENAME - pszHashItem is not a file name.
1949 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1951 void WINAPI
SHUpdateImageW(LPCWSTR pszHashItem
, int iIndex
, UINT uFlags
, int iImageIndex
)
1953 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1956 /*************************************************************************
1957 * SHUpdateImageA (SHELL32.191)
1959 * See SHUpdateImageW.
1961 VOID WINAPI
SHUpdateImageA(LPCSTR pszHashItem
, INT iIndex
, UINT uFlags
, INT iImageIndex
)
1963 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1966 INT WINAPI
SHHandleUpdateImage(LPCITEMIDLIST pidlExtra
)
1968 FIXME("%p - stub\n", pidlExtra
);
1973 BOOL WINAPI
SHObjectProperties(HWND hwnd
, DWORD dwType
, LPCWSTR szObject
, LPCWSTR szPage
)
1975 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd
, dwType
, debugstr_w(szObject
), debugstr_w(szPage
));
1980 BOOL WINAPI
SHGetNewLinkInfoA(LPCSTR pszLinkTo
, LPCSTR pszDir
, LPSTR pszName
, BOOL
*pfMustCopy
,
1983 WCHAR wszLinkTo
[MAX_PATH
];
1984 WCHAR wszDir
[MAX_PATH
];
1985 WCHAR wszName
[MAX_PATH
];
1988 MultiByteToWideChar(CP_ACP
, 0, pszLinkTo
, -1, wszLinkTo
, MAX_PATH
);
1989 MultiByteToWideChar(CP_ACP
, 0, pszDir
, -1, wszDir
, MAX_PATH
);
1991 res
= SHGetNewLinkInfoW(wszLinkTo
, wszDir
, wszName
, pfMustCopy
, uFlags
);
1994 WideCharToMultiByte(CP_ACP
, 0, wszName
, -1, pszName
, MAX_PATH
, NULL
, NULL
);
1999 BOOL WINAPI
SHGetNewLinkInfoW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
, BOOL
*pfMustCopy
,
2002 const WCHAR
*basename
;
2003 WCHAR
*dst_basename
;
2005 static const WCHAR lnkformat
[] = {'%','s','.','l','n','k',0};
2006 static const WCHAR lnkformatnum
[] = {'%','s',' ','(','%','d',')','.','l','n','k',0};
2008 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo
), debugstr_w(pszDir
),
2009 pszName
, pfMustCopy
, uFlags
);
2011 *pfMustCopy
= FALSE
;
2013 if (uFlags
& SHGNLI_PIDL
)
2015 FIXME("SHGNLI_PIDL flag unsupported\n");
2020 FIXME("ignoring flags: 0x%08x\n", uFlags
);
2022 /* FIXME: should test if the file is a shortcut or DOS program */
2023 if (GetFileAttributesW(pszLinkTo
) == INVALID_FILE_ATTRIBUTES
)
2026 basename
= strrchrW(pszLinkTo
, '\\');
2028 basename
= basename
+1;
2030 basename
= pszLinkTo
;
2032 lstrcpynW(pszName
, pszDir
, MAX_PATH
);
2033 if (!PathAddBackslashW(pszName
))
2036 dst_basename
= pszName
+ strlenW(pszName
);
2038 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformat
, basename
);
2040 while (GetFileAttributesW(pszName
) != INVALID_FILE_ATTRIBUTES
)
2042 snprintfW(dst_basename
, pszName
+ MAX_PATH
- dst_basename
, lnkformatnum
, basename
, i
);
2049 /*************************************************************************
2050 * SHStartNetConnectionDialog (SHELL32.@)
2052 HRESULT WINAPI
SHStartNetConnectionDialog(HWND hwnd
, LPCSTR pszRemoteName
, DWORD dwType
)
2054 FIXME("%p, %s, 0x%08x - stub\n", hwnd
, debugstr_a(pszRemoteName
), dwType
);
2058 /*************************************************************************
2059 * SHEmptyRecycleBinA (SHELL32.@)
2061 HRESULT WINAPI
SHEmptyRecycleBinA(HWND hwnd
, LPCSTR pszRootPath
, DWORD dwFlags
)
2063 LPWSTR szRootPathW
= NULL
;
2067 TRACE("%p, %s, 0x%08x\n", hwnd
, debugstr_a(pszRootPath
), dwFlags
);
2071 len
= MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, NULL
, 0);
2073 return HRESULT_FROM_WIN32(GetLastError());
2074 szRootPathW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
2076 return E_OUTOFMEMORY
;
2077 if (MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, szRootPathW
, len
) == 0)
2079 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2080 return HRESULT_FROM_WIN32(GetLastError());
2084 hr
= SHEmptyRecycleBinW(hwnd
, szRootPathW
, dwFlags
);
2085 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2090 HRESULT WINAPI
SHEmptyRecycleBinW(HWND hwnd
, LPCWSTR pszRootPath
, DWORD dwFlags
)
2092 WCHAR szPath
[MAX_PATH
] = {0};
2093 DWORD dwSize
, dwType
;
2096 TRACE("%p, %s, 0x%08x\n", hwnd
, debugstr_w(pszRootPath
), dwFlags
);
2098 if (!(dwFlags
& SHERB_NOCONFIRMATION
))
2101 * enumerate available files
2102 * show confirmation dialog
2104 FIXME("show confirmation dialog\n");
2107 if (dwFlags
& SHERB_NOPROGRESSUI
)
2109 ret
= EmptyRecycleBinW(pszRootPath
);
2114 * show a progress dialog
2116 ret
= EmptyRecycleBinW(pszRootPath
);
2120 return HRESULT_FROM_WIN32(GetLastError());
2122 if (!(dwFlags
& SHERB_NOSOUND
))
2124 dwSize
= sizeof(szPath
);
2125 ret
= RegGetValueW(HKEY_CURRENT_USER
,
2126 L
"AppEvents\\Schemes\\Apps\\Explorer\\EmptyRecycleBin\\.Current",
2128 RRF_RT_REG_EXPAND_SZ
,
2132 if (ret
!= ERROR_SUCCESS
)
2135 if (dwType
!= REG_EXPAND_SZ
) /* type dismatch */
2138 szPath
[(sizeof(szPath
)/sizeof(WCHAR
))-1] = L
'\0';
2139 PlaySoundW(szPath
, NULL
, SND_FILENAME
);
2144 HRESULT WINAPI
SHQueryRecycleBinA(LPCSTR pszRootPath
, LPSHQUERYRBINFO pSHQueryRBInfo
)
2146 LPWSTR szRootPathW
= NULL
;
2150 TRACE("%s, %p\n", debugstr_a(pszRootPath
), pSHQueryRBInfo
);
2154 len
= MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, NULL
, 0);
2156 return HRESULT_FROM_WIN32(GetLastError());
2157 szRootPathW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
2159 return E_OUTOFMEMORY
;
2160 if (MultiByteToWideChar(CP_ACP
, 0, pszRootPath
, -1, szRootPathW
, len
) == 0)
2162 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2163 return HRESULT_FROM_WIN32(GetLastError());
2167 hr
= SHQueryRecycleBinW(szRootPathW
, pSHQueryRBInfo
);
2168 HeapFree(GetProcessHeap(), 0, szRootPathW
);
2173 HRESULT WINAPI
SHQueryRecycleBinW(LPCWSTR pszRootPath
, LPSHQUERYRBINFO pSHQueryRBInfo
)
2175 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath
), pSHQueryRBInfo
);
2177 if (!(pszRootPath
) || (pszRootPath
[0] == 0) ||
2178 !(pSHQueryRBInfo
) || (pSHQueryRBInfo
->cbSize
< sizeof(SHQUERYRBINFO
)))
2180 return E_INVALIDARG
;
2183 pSHQueryRBInfo
->i64Size
= 0;
2184 pSHQueryRBInfo
->i64NumItems
= 0;
2189 /*************************************************************************
2190 * SHSetLocalizedName (SHELL32.@)
2192 HRESULT WINAPI
SHSetLocalizedName(LPCWSTR pszPath
, LPCWSTR pszResModule
, int idsRes
)
2194 FIXME("%p, %s, %d - stub\n", pszPath
, debugstr_w(pszResModule
), idsRes
);
2199 /*************************************************************************
2200 * LinkWindow_RegisterClass (SHELL32.258)
2202 BOOL WINAPI
LinkWindow_RegisterClass(void)
2208 /*************************************************************************
2209 * LinkWindow_UnregisterClass (SHELL32.259)
2211 BOOL WINAPI
LinkWindow_UnregisterClass(void)
2218 /*************************************************************************
2219 * SHFlushSFCache (SHELL32.526)
2221 * Notifies the shell that a user-specified special folder location has changed.
2224 * In Wine, the shell folder registry values are not cached, so this function
2227 void WINAPI
SHFlushSFCache(void)
2231 HRESULT WINAPI
SHGetImageList(int iImageList
, REFIID riid
, void **ppv
)
2233 FIXME("STUB: %i %s\n",iImageList
,debugstr_guid(riid
));
2234 return E_NOINTERFACE
;
2237 /*************************************************************************
2238 * SHParseDisplayName [shell version 6.0]
2240 HRESULT WINAPI
SHParseDisplayName(LPCWSTR pszName
, IBindCtx
*pbc
,
2241 LPITEMIDLIST
*ppidl
, SFGAOF sfgaoIn
, SFGAOF
*psfgaoOut
)
2243 IShellFolder
* psfDesktop
;
2245 ULONG dwAttr
=sfgaoIn
;
2247 if (!pszName
|| !ppidl
|| !psfgaoOut
)
2248 return E_INVALIDARG
;
2250 hr
= SHGetDesktopFolder(&psfDesktop
);
2254 hr
= IShellFolder_ParseDisplayName(psfDesktop
, (HWND
)NULL
, pbc
, (LPOLESTR
)pszName
, (ULONG
*)NULL
, ppidl
, &dwAttr
);
2256 IShellFolder_Release(psfDesktop
);
2259 *psfgaoOut
= dwAttr
;