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"
43 #include "shell32_main.h"
44 #include "undocshell.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
50 WINE_DECLARE_DEBUG_CHANNEL(pidl
);
52 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
53 /* !!! it is in both here and comctl32undoc.c !!! */
54 typedef struct tagCREATEMRULIST
56 DWORD cbSize
; /* size of struct */
57 DWORD nMaxItems
; /* max no. of items in list */
58 DWORD dwFlags
; /* see below */
59 HKEY hKey
; /* root reg. key under which list is saved */
60 LPCSTR lpszSubKey
; /* reg. subkey */
61 PROC lpfnCompare
; /* item compare proc */
62 } CREATEMRULISTA
, *LPCREATEMRULISTA
;
65 #define MRUF_STRING_LIST 0 /* list will contain strings */
66 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
67 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
69 extern HANDLE WINAPI
CreateMRUListA(LPCREATEMRULISTA lpcml
);
70 extern DWORD WINAPI
FreeMRUList(HANDLE hMRUList
);
71 extern INT WINAPI
AddMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
);
72 extern INT WINAPI
FindMRUData(HANDLE hList
, LPCVOID lpData
, DWORD cbData
, LPINT lpRegNum
);
73 extern INT WINAPI
EnumMRUListA(HANDLE hList
, INT nItemPos
, LPVOID lpBuffer
, DWORD nBufferSize
);
76 /* Get a function pointer from a DLL handle */
77 #define GET_FUNC(func, module, name, fail) \
80 if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
81 func = (void*)GetProcAddress(SHELL32_h##module, name); \
82 if (!func) return fail; \
86 /* Function pointers for GET_FUNC macro */
87 static HMODULE SHELL32_hshlwapi
=NULL
;
88 static HANDLE (WINAPI
*pSHAllocShared
)(LPCVOID
,DWORD
,DWORD
);
89 static LPVOID (WINAPI
*pSHLockShared
)(HANDLE
,DWORD
);
90 static BOOL (WINAPI
*pSHUnlockShared
)(LPVOID
);
91 static BOOL (WINAPI
*pSHFreeShared
)(HANDLE
,DWORD
);
94 /*************************************************************************
95 * ParseFieldA [internal]
97 * copies a field from a ',' delimited string
99 * first field is nField = 1
101 DWORD WINAPI
ParseFieldA(
107 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src
),nField
,dst
,len
);
109 if (!src
|| !src
[0] || !dst
|| !len
)
112 /* skip n fields delimited by ',' */
115 if (*src
=='\0') return FALSE
;
116 if (*(src
++)==',') nField
--;
119 /* copy part till the next ',' to dst */
120 while ( *src
!='\0' && *src
!=',' && (len
--)>0 ) *(dst
++)=*(src
++);
122 /* finalize the string */
128 /*************************************************************************
129 * ParseFieldW [internal]
131 * copies a field from a ',' delimited string
133 * first field is nField = 1
135 DWORD WINAPI
ParseFieldW(LPCWSTR src
, DWORD nField
, LPWSTR dst
, DWORD len
)
137 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src
), nField
, dst
, len
);
139 if (!src
|| !src
[0] || !dst
|| !len
)
142 /* skip n fields delimited by ',' */
145 if (*src
== 0x0) return FALSE
;
146 if (*src
++ == ',') nField
--;
149 /* copy part till the next ',' to dst */
150 while ( *src
!= 0x0 && *src
!= ',' && (len
--)>0 ) *(dst
++) = *(src
++);
152 /* finalize the string */
158 /*************************************************************************
159 * ParseField [SHELL32.58]
161 DWORD WINAPI
ParseFieldAW(LPCVOID src
, DWORD nField
, LPVOID dst
, DWORD len
)
163 if (SHELL_OsIsUnicode())
164 return ParseFieldW(src
, nField
, dst
, len
);
165 return ParseFieldA(src
, nField
, dst
, len
);
168 /*************************************************************************
169 * GetFileNameFromBrowse [SHELL32.63]
172 BOOL WINAPI
GetFileNameFromBrowse(
176 LPCSTR lpstrInitialDir
,
182 FARPROC pGetOpenFileNameA
;
186 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
187 hwndOwner
, lpstrFile
, nMaxFile
, lpstrInitialDir
, lpstrDefExt
,
188 lpstrFilter
, lpstrTitle
);
190 hmodule
= LoadLibraryA("comdlg32.dll");
191 if(!hmodule
) return FALSE
;
192 pGetOpenFileNameA
= GetProcAddress(hmodule
, "GetOpenFileNameA");
193 if(!pGetOpenFileNameA
)
195 FreeLibrary(hmodule
);
199 memset(&ofn
, 0, sizeof(ofn
));
201 ofn
.lStructSize
= sizeof(ofn
);
202 ofn
.hwndOwner
= hwndOwner
;
203 ofn
.lpstrFilter
= lpstrFilter
;
204 ofn
.lpstrFile
= lpstrFile
;
205 ofn
.nMaxFile
= nMaxFile
;
206 ofn
.lpstrInitialDir
= lpstrInitialDir
;
207 ofn
.lpstrTitle
= lpstrTitle
;
208 ofn
.lpstrDefExt
= lpstrDefExt
;
209 ofn
.Flags
= OFN_EXPLORER
| OFN_HIDEREADONLY
| OFN_FILEMUSTEXIST
;
210 ret
= pGetOpenFileNameA(&ofn
);
212 FreeLibrary(hmodule
);
216 /*************************************************************************
217 * SHGetSetSettings [SHELL32.68]
219 VOID WINAPI
SHGetSetSettings(LPSHELLSTATE lpss
, DWORD dwMask
, BOOL bSet
)
223 FIXME("%p 0x%08x TRUE\n", lpss
, dwMask
);
227 SHGetSettings((LPSHELLFLAGSTATE
)lpss
,dwMask
);
231 /*************************************************************************
232 * SHGetSettings [SHELL32.@]
235 * the registry path are for win98 (tested)
236 * and possibly are the same in nt40
239 VOID WINAPI
SHGetSettings(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
)
243 DWORD dwDataSize
= sizeof (DWORD
);
245 TRACE("(%p 0x%08x)\n",lpsfs
,dwMask
);
247 if (RegCreateKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
248 0, 0, 0, KEY_ALL_ACCESS
, 0, &hKey
, 0))
251 if ( (SSF_SHOWEXTENSIONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideFileExt", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
252 lpsfs
->fShowExtensions
= ((dwData
== 0) ? 0 : 1);
254 if ( (SSF_SHOWINFOTIP
& dwMask
) && !RegQueryValueExA(hKey
, "ShowInfoTip", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
255 lpsfs
->fShowInfoTip
= ((dwData
== 0) ? 0 : 1);
257 if ( (SSF_DONTPRETTYPATH
& dwMask
) && !RegQueryValueExA(hKey
, "DontPrettyPath", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
258 lpsfs
->fDontPrettyPath
= ((dwData
== 0) ? 0 : 1);
260 if ( (SSF_HIDEICONS
& dwMask
) && !RegQueryValueExA(hKey
, "HideIcons", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
261 lpsfs
->fHideIcons
= ((dwData
== 0) ? 0 : 1);
263 if ( (SSF_MAPNETDRVBUTTON
& dwMask
) && !RegQueryValueExA(hKey
, "MapNetDrvBtn", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
264 lpsfs
->fMapNetDrvBtn
= ((dwData
== 0) ? 0 : 1);
266 if ( (SSF_SHOWATTRIBCOL
& dwMask
) && !RegQueryValueExA(hKey
, "ShowAttribCol", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
267 lpsfs
->fShowAttribCol
= ((dwData
== 0) ? 0 : 1);
269 if (((SSF_SHOWALLOBJECTS
| SSF_SHOWSYSFILES
) & dwMask
) && !RegQueryValueExA(hKey
, "Hidden", 0, 0, (LPBYTE
)&dwData
, &dwDataSize
))
271 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
272 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
274 else if (dwData
== 1)
275 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 1;
276 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 0;
278 else if (dwData
== 2)
279 { if (SSF_SHOWALLOBJECTS
& dwMask
) lpsfs
->fShowAllObjects
= 0;
280 if (SSF_SHOWSYSFILES
& dwMask
) lpsfs
->fShowSysFiles
= 1;
285 TRACE("-- 0x%04x\n", *(WORD
*)lpsfs
);
288 /*************************************************************************
289 * SHShellFolderView_Message [SHELL32.73]
291 * Send a message to an explorer cabinet window.
294 * hwndCabinet [I] The window containing the shellview to communicate with
295 * dwMessage [I] The SFVM message to send
296 * dwParam [I] Message parameter
302 * Message SFVM_REARRANGE = 1
304 * This message gets sent when a column gets clicked to instruct the
305 * shell view to re-sort the item list. dwParam identifies the column
308 LRESULT WINAPI
SHShellFolderView_Message(
313 FIXME("%p %08x %08lx stub\n",hwndCabinet
, uMessage
, lParam
);
317 /*************************************************************************
318 * RegisterShellHook [SHELL32.181]
320 * Register a shell hook.
323 * hwnd [I] Window handle
324 * dwType [I] Type of hook.
327 * Exported by ordinal
329 BOOL WINAPI
RegisterShellHook(
333 FIXME("(%p,0x%08x):stub.\n",hWnd
, dwType
);
337 /*************************************************************************
338 * ShellMessageBoxW [SHELL32.182]
340 * See ShellMessageBoxA.
342 int WINAPIV
ShellMessageBoxW(
350 WCHAR szText
[100],szTitle
[100];
351 LPCWSTR pszText
= szText
, pszTitle
= szTitle
;
356 va_start(args
, uType
);
357 /* wvsprintfA(buf,fmt, args); */
359 TRACE("(%p,%p,%p,%p,%08x)\n",
360 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
362 if (IS_INTRESOURCE(lpCaption
))
363 LoadStringW(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
)/sizeof(szTitle
[0]));
365 pszTitle
= lpCaption
;
367 if (IS_INTRESOURCE(lpText
))
368 LoadStringW(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
)/sizeof(szText
[0]));
372 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
373 pszText
, 0, 0, (LPWSTR
)&pszTemp
, 0, &args
);
377 ret
= MessageBoxW(hWnd
,pszTemp
,pszTitle
,uType
);
378 LocalFree((HLOCAL
)pszTemp
);
382 /*************************************************************************
383 * ShellMessageBoxA [SHELL32.183]
385 * Format and output an error message.
388 * hInstance [I] Instance handle of message creator
389 * hWnd [I] Window handle of message creator
390 * lpText [I] Resource Id of title or LPSTR
391 * lpCaption [I] Resource Id of title or LPSTR
392 * uType [I] Type of error message
395 * A return value from MessageBoxA().
398 * Exported by ordinal
400 int WINAPIV
ShellMessageBoxA(
408 char szText
[100],szTitle
[100];
409 LPCSTR pszText
= szText
, pszTitle
= szTitle
;
414 va_start(args
, uType
);
415 /* wvsprintfA(buf,fmt, args); */
417 TRACE("(%p,%p,%p,%p,%08x)\n",
418 hInstance
,hWnd
,lpText
,lpCaption
,uType
);
420 if (IS_INTRESOURCE(lpCaption
))
421 LoadStringA(hInstance
, LOWORD(lpCaption
), szTitle
, sizeof(szTitle
));
423 pszTitle
= lpCaption
;
425 if (IS_INTRESOURCE(lpText
))
426 LoadStringA(hInstance
, LOWORD(lpText
), szText
, sizeof(szText
));
430 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
431 pszText
, 0, 0, (LPSTR
)&pszTemp
, 0, &args
);
435 ret
= MessageBoxA(hWnd
,pszTemp
,pszTitle
,uType
);
436 LocalFree((HLOCAL
)pszTemp
);
440 /*************************************************************************
441 * SHRegisterDragDrop [SHELL32.86]
443 * Probably equivalent to RegisterDragDrop but under Windows 9x it could use the
444 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
448 * exported by ordinal
451 * RegisterDragDrop, SHLoadOLE
453 HRESULT WINAPI
SHRegisterDragDrop(
455 LPDROPTARGET pDropTarget
)
457 FIXME("(%p,%p):stub.\n", hWnd
, pDropTarget
);
458 return RegisterDragDrop(hWnd
, pDropTarget
);
461 /*************************************************************************
462 * SHRevokeDragDrop [SHELL32.87]
464 * Probably equivalent to RevokeDragDrop but under Windows 9x it could use the
465 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
469 * exported by ordinal
472 * RevokeDragDrop, SHLoadOLE
474 HRESULT WINAPI
SHRevokeDragDrop(HWND hWnd
)
476 FIXME("(%p):stub.\n",hWnd
);
477 return RevokeDragDrop(hWnd
);
480 /*************************************************************************
481 * SHDoDragDrop [SHELL32.88]
483 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
484 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
488 * exported by ordinal
491 * DoDragDrop, SHLoadOLE
493 HRESULT WINAPI
SHDoDragDrop(
495 LPDATAOBJECT lpDataObject
,
496 LPDROPSOURCE lpDropSource
,
500 FIXME("(%p %p %p 0x%08x %p):stub.\n",
501 hWnd
, lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
502 return DoDragDrop(lpDataObject
, lpDropSource
, dwOKEffect
, pdwEffect
);
505 /*************************************************************************
506 * ArrangeWindows [SHELL32.184]
509 WORD WINAPI
ArrangeWindows(
516 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
517 hwndParent
, dwReserved
, lpRect
, cKids
, lpKids
);
521 /*************************************************************************
522 * SignalFileOpen [SHELL32.103]
525 * exported by ordinal
528 SignalFileOpen (DWORD dwParam1
)
530 FIXME("(0x%08x):stub.\n", dwParam1
);
535 /*************************************************************************
536 * SHADD_get_policy - helper function for SHAddToRecentDocs
539 * policy [IN] policy name (null termed string) to find
540 * type [OUT] ptr to DWORD to receive type
541 * buffer [OUT] ptr to area to hold data retrieved
542 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
546 * result of the SHQueryValueEx call
548 static INT
SHADD_get_policy(LPCSTR policy
, LPDWORD type
, LPVOID buffer
, LPDWORD len
)
553 /* Get the key for the policies location in the registry
555 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
556 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
557 0, KEY_READ
, &Policy_basekey
)) {
559 if (RegOpenKeyExA(HKEY_CURRENT_USER
,
560 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
561 0, KEY_READ
, &Policy_basekey
)) {
562 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
565 return ERROR_FILE_NOT_FOUND
;
569 /* Retrieve the data if it exists
571 ret
= SHQueryValueExA(Policy_basekey
, policy
, 0, type
, buffer
, len
);
572 RegCloseKey(Policy_basekey
);
577 /*************************************************************************
578 * SHADD_compare_mru - helper function for SHAddToRecentDocs
581 * data1 [IN] data being looked for
582 * data2 [IN] data in MRU
583 * cbdata [IN] length from FindMRUData call (not used)
586 * position within MRU list that data was added.
588 static INT CALLBACK
SHADD_compare_mru(LPCVOID data1
, LPCVOID data2
, DWORD cbData
)
590 return lstrcmpiA(data1
, data2
);
593 /*************************************************************************
594 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
597 * mruhandle [IN] handle for created MRU list
598 * doc_name [IN] null termed pure doc name
599 * new_lnk_name [IN] null termed path and file name for .lnk file
600 * buffer [IN/OUT] 2048 byte area to construct MRU data
601 * len [OUT] ptr to int to receive space used in buffer
604 * position within MRU list that data was added.
606 static INT
SHADD_create_add_mru_data(HANDLE mruhandle
, LPSTR doc_name
, LPSTR new_lnk_name
,
607 LPSTR buffer
, INT
*len
)
613 * RecentDocs MRU data structure seems to be:
614 * +0h document file name w/ terminating 0h
615 * +nh short int w/ size of remaining
616 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
617 * +n+4h 10 bytes zeros - unknown
618 * +n+eh shortcut file name w/ terminating 0h
619 * +n+e+nh 3 zero bytes - unknown
622 /* Create the MRU data structure for "RecentDocs"
625 lstrcpyA(ptr
, doc_name
);
626 ptr
+= (lstrlenA(buffer
) + 1);
627 wlen
= lstrlenA(new_lnk_name
) + 1 + 12;
628 *((short int*)ptr
) = wlen
;
629 ptr
+= 2; /* step past the length */
630 *(ptr
++) = 0x30; /* unknown reason */
631 *(ptr
++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
634 lstrcpyA(ptr
, new_lnk_name
);
635 ptr
+= (lstrlenA(new_lnk_name
) + 1);
640 /* Add the new entry into the MRU list
642 return AddMRUData(mruhandle
, (LPCVOID
)buffer
, *len
);
645 /*************************************************************************
646 * SHAddToRecentDocs [SHELL32.@]
648 * Modify (add/clear) Shell's list of recently used documents.
651 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
652 * pv [IN] string or pidl, NULL clears the list
660 void WINAPI
SHAddToRecentDocs (UINT uFlags
,LPCVOID pv
)
662 /* If list is a string list lpfnCompare has the following prototype
663 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
664 * for binary lists the prototype is
665 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
666 * where cbData is the no. of bytes to compare.
667 * Need to check what return value means identical - 0?
673 CHAR doc_name
[MAX_PATH
];
674 CHAR link_dir
[MAX_PATH
];
675 CHAR new_lnk_filepath
[MAX_PATH
];
676 CHAR new_lnk_name
[MAX_PATH
];
679 HWND hwnd
= 0; /* FIXME: get real window handle */
681 DWORD data
[64], datalen
, type
;
683 TRACE("%04x %p\n", uFlags
, pv
);
686 * RecentDocs MRU data structure seems to be:
687 * +0h document file name w/ terminating 0h
688 * +nh short int w/ size of remaining
689 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
690 * +n+4h 10 bytes zeros - unknown
691 * +n+eh shortcut file name w/ terminating 0h
692 * +n+e+nh 3 zero bytes - unknown
695 /* See if we need to do anything.
698 ret
=SHADD_get_policy( "NoRecentDocsHistory", &type
, &data
, &datalen
);
699 if ((ret
> 0) && (ret
!= ERROR_FILE_NOT_FOUND
)) {
700 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret
);
703 if (ret
== ERROR_SUCCESS
) {
704 if (!( (type
== REG_DWORD
) ||
705 ((type
== REG_BINARY
) && (datalen
== 4)) )) {
706 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
711 TRACE("policy value for NoRecentDocsHistory = %08x\n", data
[0]);
712 /* now test the actual policy value */
717 /* Open key to where the necessary info is
719 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
720 * and the close should be done during the _DETACH. The resulting
721 * key is stored in the DLL global data.
723 if (RegCreateKeyExA(HKEY_CURRENT_USER
,
724 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
725 0, 0, 0, KEY_READ
, 0, &HCUbasekey
, 0)) {
726 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
730 /* Get path to user's "Recent" directory
732 if(SUCCEEDED(SHGetMalloc(&ppM
))) {
733 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd
, CSIDL_RECENT
,
735 SHGetPathFromIDListA(pidl
, link_dir
);
736 IMalloc_Free(ppM
, pidl
);
741 ERR("serious issues 1\n");
743 IMalloc_Release(ppM
);
748 ERR("serious issues 2\n");
750 TRACE("Users Recent dir %s\n", link_dir
);
752 /* If no input, then go clear the lists */
754 /* clear user's Recent dir
757 /* FIXME: delete all files in "link_dir"
759 * while( more files ) {
760 * lstrcpyA(old_lnk_name, link_dir);
761 * PathAppendA(old_lnk_name, filenam);
762 * DeleteFileA(old_lnk_name);
765 FIXME("should delete all files in %s\\\n", link_dir
);
769 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
770 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
771 * and naturally it fails w/ rc=2. It should do it against
772 * HKEY_CURRENT_USER which is where it is stored, and where
773 * the MRU routines expect it!!!!
775 RegDeleteKeyA(HCUbasekey
, "RecentDocs");
776 RegCloseKey(HCUbasekey
);
780 /* Have data to add, the jobs to be done:
781 * 1. Add document to MRU list in registry "HKCU\Software\
782 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
783 * 2. Add shortcut to document in the user's Recent directory
785 * 3. Add shortcut to Start menu's Documents submenu.
788 /* Get the pure document name from the input
793 SHGetPathFromIDListA((LPCITEMIDLIST
) pv
, doc_name
);
797 lstrcpynA(doc_name
, (LPCSTR
)pv
, MAX_PATH
);
801 WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)pv
, -1, doc_name
, MAX_PATH
, NULL
, NULL
);
805 FIXME("Unsupported flags: %u\n", uFlags
);
809 TRACE("full document name %s\n", debugstr_a(doc_name
));
810 PathStripPathA(doc_name
);
811 TRACE("stripped document name %s\n", debugstr_a(doc_name
));
814 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
817 * doc_name - pure file-spec, no path
818 * link_dir - path to the user's Recent directory
819 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
821 * new_lnk_name- pure file-spec, no path for new .lnk file
823 * - path and file name of new .lnk file
825 CREATEMRULISTA mymru
;
827 INT len
, pos
, bufused
, err
;
832 CHAR old_lnk_name
[MAX_PATH
];
835 mymru
.cbSize
= sizeof(CREATEMRULISTA
);
836 mymru
.nMaxItems
= 15;
837 mymru
.dwFlags
= MRUF_BINARY_LIST
| MRUF_DELAYED_SAVE
;
838 mymru
.hKey
= HCUbasekey
;
839 mymru
.lpszSubKey
= "RecentDocs";
840 mymru
.lpfnCompare
= (PROC
)SHADD_compare_mru
;
841 mruhandle
= CreateMRUListA(&mymru
);
844 ERR("MRU processing failed, handle zero\n");
845 RegCloseKey(HCUbasekey
);
848 len
= lstrlenA(doc_name
);
849 pos
= FindMRUData(mruhandle
, doc_name
, len
, 0);
851 /* Now get the MRU entry that will be replaced
852 * and delete the .lnk file for it
854 if ((bufused
= EnumMRUListA(mruhandle
, (pos
== -1) ? 14 : pos
,
855 buffer
, 2048)) != -1) {
857 ptr
+= (lstrlenA(buffer
) + 1);
858 slen
= *((short int*)ptr
);
859 ptr
+= 2; /* skip the length area */
860 if (bufused
>= slen
+ (ptr
-buffer
)) {
861 /* buffer size looks good */
862 ptr
+= 12; /* get to string */
863 len
= bufused
- (ptr
-buffer
); /* get length of buf remaining */
864 if ((lstrlenA(ptr
) > 0) && (lstrlenA(ptr
) <= len
-1)) {
865 /* appears to be good string */
866 lstrcpyA(old_lnk_name
, link_dir
);
867 PathAppendA(old_lnk_name
, ptr
);
868 if (!DeleteFileA(old_lnk_name
)) {
869 if ((attr
= GetFileAttributesA(old_lnk_name
)) == INVALID_FILE_ATTRIBUTES
) {
870 if ((err
= GetLastError()) != ERROR_FILE_NOT_FOUND
) {
871 ERR("Delete for %s failed, err=%d, attr=%08x\n",
872 old_lnk_name
, err
, attr
);
875 TRACE("old .lnk file %s did not exist\n",
880 ERR("Delete for %s failed, attr=%08x\n",
885 TRACE("deleted old .lnk file %s\n", old_lnk_name
);
891 /* Create usable .lnk file name for the "Recent" directory
893 wsprintfA(new_lnk_name
, "%s.lnk", doc_name
);
894 lstrcpyA(new_lnk_filepath
, link_dir
);
895 PathAppendA(new_lnk_filepath
, new_lnk_name
);
897 olderrormode
= SetErrorMode(SEM_FAILCRITICALERRORS
);
898 while (GetFileAttributesA(new_lnk_filepath
) != INVALID_FILE_ATTRIBUTES
) {
900 wsprintfA(new_lnk_name
, "%s (%u).lnk", doc_name
, i
);
901 lstrcpyA(new_lnk_filepath
, link_dir
);
902 PathAppendA(new_lnk_filepath
, new_lnk_name
);
904 SetErrorMode(olderrormode
);
905 TRACE("new shortcut will be %s\n", new_lnk_filepath
);
907 /* Now add the new MRU entry and data
909 pos
= SHADD_create_add_mru_data(mruhandle
, doc_name
, new_lnk_name
,
911 FreeMRUList(mruhandle
);
912 TRACE("Updated MRU list, new doc is position %d\n", pos
);
915 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
918 * doc_name - pure file-spec, no path
920 * - path and file name of new .lnk file
921 * uFlags[in] - flags on call to SHAddToRecentDocs
922 * pv[in] - document path/pidl on call to SHAddToRecentDocs
924 IShellLinkA
*psl
= NULL
;
925 IPersistFile
*pPf
= NULL
;
928 WCHAR widelink
[MAX_PATH
];
932 hres
= CoCreateInstance( &CLSID_ShellLink
,
934 CLSCTX_INPROC_SERVER
,
937 if(SUCCEEDED(hres
)) {
939 hres
= IShellLinkA_QueryInterface(psl
, &IID_IPersistFile
,
943 ERR("failed QueryInterface for IPersistFile %08x\n", hres
);
947 /* Set the document path or pidl */
948 if (uFlags
== SHARD_PIDL
) {
949 hres
= IShellLinkA_SetIDList(psl
, (LPCITEMIDLIST
) pv
);
951 hres
= IShellLinkA_SetPath(psl
, (LPCSTR
) pv
);
955 ERR("failed Set{IDList|Path} %08x\n", hres
);
959 lstrcpyA(desc
, "Shortcut to ");
960 lstrcatA(desc
, doc_name
);
961 hres
= IShellLinkA_SetDescription(psl
, desc
);
964 ERR("failed SetDescription %08x\n", hres
);
968 MultiByteToWideChar(CP_ACP
, 0, new_lnk_filepath
, -1,
970 /* create the short cut */
971 hres
= IPersistFile_Save(pPf
, widelink
, TRUE
);
974 ERR("failed IPersistFile::Save %08x\n", hres
);
975 IPersistFile_Release(pPf
);
976 IShellLinkA_Release(psl
);
979 hres
= IPersistFile_SaveCompleted(pPf
, widelink
);
980 IPersistFile_Release(pPf
);
981 IShellLinkA_Release(psl
);
982 TRACE("shortcut %s has been created, result=%08x\n",
983 new_lnk_filepath
, hres
);
986 ERR("CoCreateInstance failed, hres=%08x\n", hres
);
994 RegCloseKey(HCUbasekey
);
998 /*************************************************************************
999 * SHCreateShellFolderViewEx [SHELL32.174]
1001 * Create a new instance of the default Shell folder view object.
1005 * Failure: error value
1008 * see IShellFolder::CreateViewObject
1010 HRESULT WINAPI
SHCreateShellFolderViewEx(
1011 LPCSFV psvcbi
, /* [in] shelltemplate struct */
1012 IShellView
**ppv
) /* [out] IShellView pointer */
1017 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1018 psvcbi
->pshf
, psvcbi
->pidl
, psvcbi
->pfnCallback
,
1019 psvcbi
->fvm
, psvcbi
->psvOuter
);
1021 psf
= IShellView_Constructor(psvcbi
->pshf
);
1024 return E_OUTOFMEMORY
;
1026 IShellView_AddRef(psf
);
1027 hRes
= IShellView_QueryInterface(psf
, &IID_IShellView
, (LPVOID
*)ppv
);
1028 IShellView_Release(psf
);
1032 /*************************************************************************
1033 * SHWinHelp [SHELL32.127]
1036 HRESULT WINAPI
SHWinHelp (DWORD v
, DWORD w
, DWORD x
, DWORD z
)
1037 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v
,w
,x
,z
);
1040 /*************************************************************************
1041 * SHRunControlPanel [SHELL32.161]
1044 HRESULT WINAPI
SHRunControlPanel (DWORD x
, DWORD z
)
1045 { FIXME("0x%08x 0x%08x stub\n",x
,z
);
1049 static LPUNKNOWN SHELL32_IExplorerInterface
=0;
1050 /*************************************************************************
1051 * SHSetInstanceExplorer [SHELL32.176]
1054 * Sets the interface
1056 VOID WINAPI
SHSetInstanceExplorer (LPUNKNOWN lpUnknown
)
1057 { TRACE("%p\n", lpUnknown
);
1058 SHELL32_IExplorerInterface
= lpUnknown
;
1060 /*************************************************************************
1061 * SHGetInstanceExplorer [SHELL32.@]
1064 * gets the interface pointer of the explorer and a reference
1066 HRESULT WINAPI
SHGetInstanceExplorer (IUnknown
**lpUnknown
)
1067 { TRACE("%p\n", lpUnknown
);
1069 *lpUnknown
= SHELL32_IExplorerInterface
;
1071 if (!SHELL32_IExplorerInterface
)
1074 IUnknown_AddRef(SHELL32_IExplorerInterface
);
1077 /*************************************************************************
1078 * SHFreeUnusedLibraries [SHELL32.123]
1080 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1081 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1085 * exported by ordinal
1088 * CoFreeUnusedLibraries, SHLoadOLE
1090 void WINAPI
SHFreeUnusedLibraries (void)
1093 CoFreeUnusedLibraries();
1095 /*************************************************************************
1096 * DAD_AutoScroll [SHELL32.129]
1099 BOOL WINAPI
DAD_AutoScroll(HWND hwnd
, AUTO_SCROLL_DATA
*samples
, LPPOINT pt
)
1101 FIXME("hwnd = %p %p %p\n",hwnd
,samples
,pt
);
1104 /*************************************************************************
1105 * DAD_DragEnter [SHELL32.130]
1108 BOOL WINAPI
DAD_DragEnter(HWND hwnd
)
1110 FIXME("hwnd = %p\n",hwnd
);
1113 /*************************************************************************
1114 * DAD_DragEnterEx [SHELL32.131]
1117 BOOL WINAPI
DAD_DragEnterEx(HWND hwnd
, POINT p
)
1119 FIXME("hwnd = %p (%d,%d)\n",hwnd
,p
.x
,p
.y
);
1122 /*************************************************************************
1123 * DAD_DragMove [SHELL32.134]
1126 BOOL WINAPI
DAD_DragMove(POINT p
)
1128 FIXME("(%d,%d)\n",p
.x
,p
.y
);
1131 /*************************************************************************
1132 * DAD_DragLeave [SHELL32.132]
1135 BOOL WINAPI
DAD_DragLeave(VOID
)
1140 /*************************************************************************
1141 * DAD_SetDragImage [SHELL32.136]
1146 BOOL WINAPI
DAD_SetDragImage(
1147 HIMAGELIST himlTrack
,
1150 FIXME("%p %p stub\n",himlTrack
, lppt
);
1153 /*************************************************************************
1154 * DAD_ShowDragImage [SHELL32.137]
1159 BOOL WINAPI
DAD_ShowDragImage(BOOL bShow
)
1161 FIXME("0x%08x stub\n",bShow
);
1165 static const WCHAR szwCabLocation
[] = {
1166 'S','o','f','t','w','a','r','e','\\',
1167 'M','i','c','r','o','s','o','f','t','\\',
1168 'W','i','n','d','o','w','s','\\',
1169 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1170 'E','x','p','l','o','r','e','r','\\',
1171 'C','a','b','i','n','e','t','S','t','a','t','e',0
1174 static const WCHAR szwSettings
[] = { 'S','e','t','t','i','n','g','s',0 };
1176 /*************************************************************************
1177 * ReadCabinetState [SHELL32.651] NT 4.0
1180 BOOL WINAPI
ReadCabinetState(CABINETSTATE
*cs
, int length
)
1185 TRACE("%p %d\n", cs
, length
);
1187 if( (cs
== NULL
) || (length
< (int)sizeof(*cs
)) )
1190 r
= RegOpenKeyW( HKEY_CURRENT_USER
, szwCabLocation
, &hkey
);
1191 if( r
== ERROR_SUCCESS
)
1194 r
= RegQueryValueExW( hkey
, szwSettings
,
1195 NULL
, &type
, (LPBYTE
)cs
, (LPDWORD
)&length
);
1196 RegCloseKey( hkey
);
1200 /* if we can't read from the registry, create default values */
1201 if ( (r
!= ERROR_SUCCESS
) || (cs
->cLength
< sizeof(*cs
)) ||
1202 (cs
->cLength
!= length
) )
1204 ERR("Initializing shell cabinet settings\n");
1205 memset(cs
, 0, sizeof(*cs
));
1206 cs
->cLength
= sizeof(*cs
);
1208 cs
->fFullPathTitle
= FALSE
;
1209 cs
->fSaveLocalView
= TRUE
;
1210 cs
->fNotShell
= FALSE
;
1211 cs
->fSimpleDefault
= TRUE
;
1212 cs
->fDontShowDescBar
= FALSE
;
1213 cs
->fNewWindowMode
= FALSE
;
1214 cs
->fShowCompColor
= FALSE
;
1215 cs
->fDontPrettyNames
= FALSE
;
1216 cs
->fAdminsCreateCommonGroups
= TRUE
;
1217 cs
->fMenuEnumFilter
= 96;
1223 /*************************************************************************
1224 * WriteCabinetState [SHELL32.652] NT 4.0
1227 BOOL WINAPI
WriteCabinetState(CABINETSTATE
*cs
)
1237 r
= RegCreateKeyExW( HKEY_CURRENT_USER
, szwCabLocation
, 0,
1238 NULL
, 0, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
);
1239 if( r
== ERROR_SUCCESS
)
1241 r
= RegSetValueExW( hkey
, szwSettings
, 0,
1242 REG_BINARY
, (LPBYTE
) cs
, cs
->cLength
);
1244 RegCloseKey( hkey
);
1247 return (r
==ERROR_SUCCESS
);
1250 /*************************************************************************
1251 * FileIconInit [SHELL32.660]
1254 BOOL WINAPI
FileIconInit(BOOL bFullInit
)
1255 { FIXME("(%s)\n", bFullInit
? "true" : "false");
1258 /*************************************************************************
1259 * IsUserAdmin [SHELL32.680] NT 4.0
1262 HRESULT WINAPI
IsUserAdmin(void)
1267 /*************************************************************************
1268 * SHAllocShared [SHELL32.520]
1270 * See shlwapi.SHAllocShared
1272 HANDLE WINAPI
SHAllocShared(LPVOID lpvData
, DWORD dwSize
, DWORD dwProcId
)
1274 GET_FUNC(pSHAllocShared
, shlwapi
, (char*)7, NULL
);
1275 return pSHAllocShared(lpvData
, dwSize
, dwProcId
);
1278 /*************************************************************************
1279 * SHLockShared [SHELL32.521]
1281 * See shlwapi.SHLockShared
1283 LPVOID WINAPI
SHLockShared(HANDLE hShared
, DWORD dwProcId
)
1285 GET_FUNC(pSHLockShared
, shlwapi
, (char*)8, NULL
);
1286 return pSHLockShared(hShared
, dwProcId
);
1289 /*************************************************************************
1290 * SHUnlockShared [SHELL32.522]
1292 * See shlwapi.SHUnlockShared
1294 BOOL WINAPI
SHUnlockShared(LPVOID lpView
)
1296 GET_FUNC(pSHUnlockShared
, shlwapi
, (char*)9, FALSE
);
1297 return pSHUnlockShared(lpView
);
1300 /*************************************************************************
1301 * SHFreeShared [SHELL32.523]
1303 * See shlwapi.SHFreeShared
1305 BOOL WINAPI
SHFreeShared(HANDLE hShared
, DWORD dwProcId
)
1307 GET_FUNC(pSHFreeShared
, shlwapi
, (char*)10, FALSE
);
1308 return pSHFreeShared(hShared
, dwProcId
);
1311 /*************************************************************************
1312 * SetAppStartingCursor [SHELL32.99]
1314 HRESULT WINAPI
SetAppStartingCursor(HWND u
, DWORD v
)
1315 { FIXME("hwnd=%p 0x%04x stub\n",u
,v
);
1319 /*************************************************************************
1320 * SHLoadOLE [SHELL32.151]
1322 * To reduce the memory usage of Windows 95, its shell32 contained an
1323 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1324 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1325 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1326 * would just call the Co* functions.
1328 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1329 * information from the shell32 "mini-COM" to ole32.dll.
1331 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1332 * detailed description.
1334 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1335 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1336 * hack in SHCoCreateInstance)
1338 HRESULT WINAPI
SHLoadOLE(LPARAM lParam
)
1339 { FIXME("0x%08lx stub\n",lParam
);
1342 /*************************************************************************
1343 * DriveType [SHELL32.64]
1346 HRESULT WINAPI
DriveType(DWORD u
)
1347 { FIXME("0x%04x stub\n",u
);
1350 /*************************************************************************
1351 * InvalidateDriveType [SHELL32.65]
1354 int WINAPI
InvalidateDriveType(int u
)
1355 { FIXME("0x%08x stub\n",u
);
1358 /*************************************************************************
1359 * SHAbortInvokeCommand [SHELL32.198]
1362 HRESULT WINAPI
SHAbortInvokeCommand(void)
1366 /*************************************************************************
1367 * SHOutOfMemoryMessageBox [SHELL32.126]
1370 int WINAPI
SHOutOfMemoryMessageBox(
1375 FIXME("%p %s 0x%08x stub\n",hwndOwner
, lpCaption
, uType
);
1378 /*************************************************************************
1379 * SHFlushClipboard [SHELL32.121]
1382 HRESULT WINAPI
SHFlushClipboard(void)
1387 /*************************************************************************
1388 * SHWaitForFileToOpen [SHELL32.97]
1391 BOOL WINAPI
SHWaitForFileToOpen(
1396 FIXME("%p 0x%08x 0x%08x stub\n", pidl
, dwFlags
, dwTimeout
);
1400 /************************************************************************
1404 * first parameter seems to be a pointer (same as passed to WriteCabinetState)
1405 * second one could be a size (0x0c). The size is the same as the structure saved to
1406 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1407 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1409 HRESULT WINAPI
shell32_654 (CABINETSTATE
*cs
, int length
)
1411 TRACE("%p %d\n",cs
,length
);
1412 return ReadCabinetState(cs
,length
);
1415 /************************************************************************
1416 * RLBuildListOfPaths [SHELL32.146]
1421 DWORD WINAPI
RLBuildListOfPaths (void)
1425 /************************************************************************
1426 * SHValidateUNC [SHELL32.173]
1429 HRESULT WINAPI
SHValidateUNC (DWORD x
, DWORD y
, DWORD z
)
1431 FIXME("0x%08x 0x%08x 0x%08x stub\n",x
,y
,z
);
1435 /************************************************************************
1436 * DoEnvironmentSubstA [SHELL32.@]
1438 * Replace %KEYWORD% in the str with the value of variable KEYWORD
1439 * from environment. If it is not found the %KEYWORD% is left
1440 * intact. If the buffer is too small, str is not modified.
1443 * pszString [I] '\0' terminated string with %keyword%.
1444 * [O] '\0' terminated string with %keyword% substituted.
1445 * cchString [I] size of str.
1448 * cchString length in the HIWORD;
1449 * TRUE in LOWORD if subst was successful and FALSE in other case
1451 DWORD WINAPI
DoEnvironmentSubstA(LPSTR pszString
, UINT cchString
)
1455 FIXME("(%s, %d) stub\n", debugstr_a(pszString
), cchString
);
1456 if (pszString
== NULL
) /* Really return 0? */
1458 if ((dst
= HeapAlloc(GetProcessHeap(), 0, cchString
* sizeof(CHAR
))))
1460 DWORD num
= ExpandEnvironmentStringsA(pszString
, dst
, cchString
);
1461 if (num
&& num
< cchString
) /* dest buffer is too small */
1464 memcpy(pszString
, dst
, num
);
1466 HeapFree(GetProcessHeap(), 0, dst
);
1468 return MAKELONG(res
,cchString
); /* Always cchString? */
1471 /************************************************************************
1472 * DoEnvironmentSubstW [SHELL32.@]
1474 * See DoEnvironmentSubstA.
1476 DWORD WINAPI
DoEnvironmentSubstW(LPWSTR pszString
, UINT cchString
)
1478 FIXME("(%s, %d): stub\n", debugstr_w(pszString
), cchString
);
1479 return MAKELONG(FALSE
,cchString
);
1482 /************************************************************************
1483 * DoEnvironmentSubst [SHELL32.53]
1485 * See DoEnvironmentSubstA.
1487 DWORD WINAPI
DoEnvironmentSubstAW(LPVOID x
, UINT y
)
1489 if (SHELL_OsIsUnicode())
1490 return DoEnvironmentSubstW(x
, y
);
1491 return DoEnvironmentSubstA(x
, y
);
1494 /*************************************************************************
1497 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1498 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1502 BOOL WINAPI
shell32_243(DWORD a
, DWORD b
)
1507 /*************************************************************************
1510 DWORD WINAPI
SHELL32_714(LPVOID x
)
1512 FIXME("(%s)stub\n", debugstr_w(x
));
1516 typedef struct _PSXA
1520 IShellPropSheetExt
*pspsx
[1];
1523 typedef struct _PSXA_CALL
1525 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith
;
1530 } PSXA_CALL
, *PPSXA_CALL
;
1532 static BOOL CALLBACK
PsxaCall(HPROPSHEETPAGE hpage
, LPARAM lParam
)
1534 PPSXA_CALL Call
= (PPSXA_CALL
)lParam
;
1538 if ((Call
->bMultiple
|| !Call
->bCalled
) &&
1539 Call
->lpfnAddReplaceWith(hpage
, Call
->lParam
))
1541 Call
->bCalled
= TRUE
;
1550 /*************************************************************************
1551 * SHAddFromPropSheetExtArray [SHELL32.167]
1553 UINT WINAPI
SHAddFromPropSheetExtArray(HPSXA hpsxa
, LPFNADDPROPSHEETPAGE lpfnAddPage
, LPARAM lParam
)
1557 PPSXA psxa
= (PPSXA
)hpsxa
;
1559 TRACE("(%p,%p,%08lx)\n", hpsxa
, lpfnAddPage
, lParam
);
1563 ZeroMemory(&Call
, sizeof(Call
));
1564 Call
.lpfnAddReplaceWith
= lpfnAddPage
;
1565 Call
.lParam
= lParam
;
1566 Call
.bMultiple
= TRUE
;
1568 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1569 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1571 psxa
->pspsx
[i
]->lpVtbl
->AddPages(psxa
->pspsx
[i
], PsxaCall
, (LPARAM
)&Call
);
1574 return Call
.uiCount
;
1580 /*************************************************************************
1581 * SHCreatePropSheetExtArray [SHELL32.168]
1583 HPSXA WINAPI
SHCreatePropSheetExtArray(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
)
1585 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};
1586 WCHAR szHandler
[64];
1588 WCHAR szClsidHandler
[39];
1593 IShellExtInit
*psxi
;
1594 IShellPropSheetExt
*pspsx
;
1595 HKEY hkBase
, hkPropSheetHandlers
;
1598 TRACE("(%p,%s,%u)\n", hKey
, debugstr_w(pszSubKey
), max_iface
);
1603 /* Open the registry key */
1604 lRet
= RegOpenKeyW(hKey
, pszSubKey
, &hkBase
);
1605 if (lRet
!= ERROR_SUCCESS
)
1608 lRet
= RegOpenKeyExW(hkBase
, szPropSheetSubKey
, 0, KEY_ENUMERATE_SUB_KEYS
, &hkPropSheetHandlers
);
1609 RegCloseKey(hkBase
);
1610 if (lRet
== ERROR_SUCCESS
)
1612 /* Create and initialize the Property Sheet Extensions Array */
1613 psxa
= (PPSXA
)LocalAlloc(LMEM_FIXED
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1616 ZeroMemory(psxa
, FIELD_OFFSET(PSXA
, pspsx
[max_iface
]));
1617 psxa
->uiAllocated
= max_iface
;
1619 /* Enumerate all subkeys and attempt to load the shell extensions */
1623 dwHandlerLen
= sizeof(szHandler
) / sizeof(szHandler
[0]);
1624 lRet
= RegEnumKeyExW(hkPropSheetHandlers
, dwIndex
++, szHandler
, &dwHandlerLen
, NULL
, NULL
, NULL
, NULL
);
1625 if (lRet
!= ERROR_SUCCESS
)
1627 if (lRet
== ERROR_MORE_DATA
)
1630 if (lRet
== ERROR_NO_MORE_ITEMS
)
1631 lRet
= ERROR_SUCCESS
;
1635 dwClsidSize
= sizeof(szClsidHandler
);
1636 if (SHGetValueW(hkPropSheetHandlers
, szHandler
, NULL
, NULL
, szClsidHandler
, &dwClsidSize
) == ERROR_SUCCESS
)
1638 /* Force a NULL-termination and convert the string */
1639 szClsidHandler
[(sizeof(szClsidHandler
) / sizeof(szClsidHandler
[0])) - 1] = 0;
1640 if (SUCCEEDED(SHCLSIDFromStringW(szClsidHandler
, &clsid
)))
1642 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1643 Only if both interfaces are supported it's a real shell extension.
1644 Then call IShellExtInit's Initialize method. */
1645 if (SUCCEEDED(CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt
, (LPVOID
*)&pspsx
)))
1647 if (SUCCEEDED(pspsx
->lpVtbl
->QueryInterface(pspsx
, &IID_IShellExtInit
, (PVOID
*)&psxi
)))
1649 if (SUCCEEDED(psxi
->lpVtbl
->Initialize(psxi
, NULL
, NULL
, hKey
)))
1651 /* Add the IShellPropSheetExt instance to the array */
1652 psxa
->pspsx
[psxa
->uiCount
++] = pspsx
;
1656 psxi
->lpVtbl
->Release(psxi
);
1657 pspsx
->lpVtbl
->Release(pspsx
);
1661 pspsx
->lpVtbl
->Release(pspsx
);
1666 } while (psxa
->uiCount
!= psxa
->uiAllocated
);
1669 lRet
= ERROR_NOT_ENOUGH_MEMORY
;
1671 RegCloseKey(hkPropSheetHandlers
);
1674 if (lRet
!= ERROR_SUCCESS
&& psxa
)
1676 SHDestroyPropSheetExtArray((HPSXA
)psxa
);
1683 /*************************************************************************
1684 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1686 UINT WINAPI
SHReplaceFromPropSheetExtArray(HPSXA hpsxa
, UINT uPageID
, LPFNADDPROPSHEETPAGE lpfnReplaceWith
, LPARAM lParam
)
1690 PPSXA psxa
= (PPSXA
)hpsxa
;
1692 TRACE("(%p,%u,%p,%08lx)\n", hpsxa
, uPageID
, lpfnReplaceWith
, lParam
);
1696 ZeroMemory(&Call
, sizeof(Call
));
1697 Call
.lpfnAddReplaceWith
= lpfnReplaceWith
;
1698 Call
.lParam
= lParam
;
1700 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1701 Each shell extension is only allowed to call the callback once during the callback. */
1702 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1704 Call
.bCalled
= FALSE
;
1705 psxa
->pspsx
[i
]->lpVtbl
->ReplacePage(psxa
->pspsx
[i
], uPageID
, PsxaCall
, (LPARAM
)&Call
);
1708 return Call
.uiCount
;
1714 /*************************************************************************
1715 * SHDestroyPropSheetExtArray [SHELL32.169]
1717 void WINAPI
SHDestroyPropSheetExtArray(HPSXA hpsxa
)
1720 PPSXA psxa
= (PPSXA
)hpsxa
;
1722 TRACE("(%p)\n", hpsxa
);
1726 for (i
= 0; i
!= psxa
->uiCount
; i
++)
1728 psxa
->pspsx
[i
]->lpVtbl
->Release(psxa
->pspsx
[i
]);
1731 LocalFree((HLOCAL
)psxa
);
1735 /*************************************************************************
1736 * CIDLData_CreateFromIDArray [SHELL32.83]
1738 * Create IDataObject from PIDLs??
1740 HRESULT WINAPI
CIDLData_CreateFromIDArray(
1741 LPCITEMIDLIST pidlFolder
,
1743 LPCITEMIDLIST
*lppidlFiles
,
1744 LPDATAOBJECT
*ppdataObject
)
1747 HWND hwnd
= 0; /*FIXME: who should be hwnd of owner? set to desktop */
1749 TRACE("(%p, %d, %p, %p)\n", pidlFolder
, cpidlFiles
, lppidlFiles
, ppdataObject
);
1753 for (i
=0; i
<cpidlFiles
; i
++) pdump (lppidlFiles
[i
]);
1755 *ppdataObject
= IDataObject_Constructor( hwnd
, pidlFolder
,
1756 lppidlFiles
, cpidlFiles
);
1757 if (*ppdataObject
) return S_OK
;
1758 return E_OUTOFMEMORY
;
1761 /*************************************************************************
1762 * SHCreateStdEnumFmtEtc [SHELL32.74]
1767 HRESULT WINAPI
SHCreateStdEnumFmtEtc(
1769 const FORMATETC
*lpFormats
,
1770 LPENUMFORMATETC
*ppenumFormatetc
)
1772 IEnumFORMATETC
*pef
;
1774 TRACE("cf=%d fe=%p pef=%p\n", cFormats
, lpFormats
, ppenumFormatetc
);
1776 pef
= IEnumFORMATETC_Constructor(cFormats
, lpFormats
);
1778 return E_OUTOFMEMORY
;
1780 IEnumFORMATETC_AddRef(pef
);
1781 hRes
= IEnumFORMATETC_QueryInterface(pef
, &IID_IEnumFORMATETC
, (LPVOID
*)ppenumFormatetc
);
1782 IEnumFORMATETC_Release(pef
);
1788 /*************************************************************************
1789 * SHELL32_256 (SHELL32.256)
1791 HRESULT WINAPI
SHELL32_256(LPDWORD lpdw0
, LPDWORD lpdw1
)
1795 FIXME("stub %p 0x%08x %p\n", lpdw0
, lpdw0
? *lpdw0
: 0, lpdw1
);
1797 if (!lpdw0
|| *lpdw0
!= 0x10)
1801 LPVOID lpdata
= 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1804 ret
= E_OUTOFMEMORY
;
1807 /* Initialize and return unknown lpdata structure */
1814 /*************************************************************************
1815 * SHFindFiles (SHELL32.90)
1817 BOOL WINAPI
SHFindFiles( LPCITEMIDLIST pidlFolder
, LPCITEMIDLIST pidlSaveFile
)
1819 FIXME("%p %p\n", pidlFolder
, pidlSaveFile
);
1823 /*************************************************************************
1824 * SHUpdateImageW (SHELL32.192)
1826 * Notifies the shell that an icon in the system image list has been changed.
1829 * pszHashItem [I] Path to file that contains the icon.
1830 * iIndex [I] Zero-based index of the icon in the file.
1831 * uFlags [I] Flags determining the icon attributes. See notes.
1832 * iImageIndex [I] Index of the icon in the system image list.
1838 * uFlags can be one or more of the following flags:
1839 * GIL_NOTFILENAME - pszHashItem is not a file name.
1840 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1842 void WINAPI
SHUpdateImageW(LPCWSTR pszHashItem
, int iIndex
, UINT uFlags
, int iImageIndex
)
1844 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1847 /*************************************************************************
1848 * SHUpdateImageA (SHELL32.191)
1850 * See SHUpdateImageW.
1852 VOID WINAPI
SHUpdateImageA(LPCSTR pszHashItem
, INT iIndex
, UINT uFlags
, INT iImageIndex
)
1854 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem
), iIndex
, uFlags
, iImageIndex
);
1857 INT WINAPI
SHHandleUpdateImage(LPCITEMIDLIST pidlExtra
)
1859 FIXME("%p - stub\n", pidlExtra
);
1864 BOOL WINAPI
SHObjectProperties(HWND hwnd
, DWORD dwType
, LPCWSTR szObject
, LPCWSTR szPage
)
1866 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd
, dwType
, debugstr_w(szObject
), debugstr_w(szPage
));
1871 BOOL WINAPI
SHGetNewLinkInfoA(LPCSTR pszLinkTo
, LPCSTR pszDir
, LPSTR pszName
, BOOL
*pfMustCopy
,
1874 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo
), debugstr_a(pszDir
),
1875 pszName
, pfMustCopy
, uFlags
);
1880 BOOL WINAPI
SHGetNewLinkInfoW(LPCWSTR pszLinkTo
, LPCWSTR pszDir
, LPWSTR pszName
, BOOL
*pfMustCopy
,
1883 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo
), debugstr_w(pszDir
),
1884 pszName
, pfMustCopy
, uFlags
);
1889 HRESULT WINAPI
SHStartNetConnectionDialog(HWND hwnd
, LPCSTR pszRemoteName
, DWORD dwType
)
1891 FIXME("%p, %s, 0x%08x - stub\n", hwnd
, debugstr_a(pszRemoteName
), dwType
);
1896 HRESULT WINAPI
SHEmptyRecycleBinA(HWND hwnd
, LPCSTR pszRootPath
, DWORD dwFlags
)
1898 FIXME("%p, %s, 0x%08x - stub\n", hwnd
, debugstr_a(pszRootPath
), dwFlags
);
1903 HRESULT WINAPI
SHEmptyRecycleBinW(HWND hwnd
, LPCWSTR pszRootPath
, DWORD dwFlags
)
1905 FIXME("%p, %s, 0x%08x - stub\n", hwnd
, debugstr_w(pszRootPath
), dwFlags
);
1910 DWORD WINAPI
SHFormatDrive(HWND hwnd
, UINT drive
, UINT fmtID
, UINT options
)
1912 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd
, drive
, fmtID
, options
);
1914 return SHFMT_NOFORMAT
;
1917 HRESULT WINAPI
SHQueryRecycleBinA(LPCSTR pszRootPath
, LPSHQUERYRBINFO pSHQueryRBInfo
)
1919 FIXME("%s, %p - stub\n", debugstr_a(pszRootPath
), pSHQueryRBInfo
);
1921 pSHQueryRBInfo
->i64Size
= 0;
1922 pSHQueryRBInfo
->i64NumItems
= 0;
1927 HRESULT WINAPI
SHQueryRecycleBinW(LPCWSTR pszRootPath
, LPSHQUERYRBINFO pSHQueryRBInfo
)
1929 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath
), pSHQueryRBInfo
);
1931 pSHQueryRBInfo
->i64Size
= 0;
1932 pSHQueryRBInfo
->i64NumItems
= 0;
1937 /*************************************************************************
1938 * SHSetLocalizedName (SHELL32.@)
1940 HRESULT WINAPI
SHSetLocalizedName(LPWSTR pszPath
, LPCWSTR pszResModule
, int idsRes
)
1942 FIXME("%p, %s, %d - stub\n", pszPath
, debugstr_w(pszResModule
), idsRes
);