shell32: Add stub for ordinal 526.
[wine.git] / dlls / shell32 / shellord.c
blob2b7103cd112bc740188fbf2ecc492092255cfff7
1 /*
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
6 * 1998 Jürgen Schmied
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
22 #include "config.h"
24 #include <string.h>
25 #include <stdarg.h>
26 #include <stdio.h>
28 #define COBJMACROS
30 #include "winerror.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winreg.h"
34 #include "wine/debug.h"
35 #include "winnls.h"
37 #include "shellapi.h"
38 #include "objbase.h"
39 #include "shlguid.h"
40 #include "wingdi.h"
41 #include "winuser.h"
42 #include "shlobj.h"
43 #include "shell32_main.h"
44 #include "undocshell.h"
45 #include "pidl.h"
46 #include "shlwapi.h"
47 #include "commdlg.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;
64 /* dwFlags */
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) \
78 do { \
79 if (!func) { \
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; \
83 } \
84 } while (0)
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(
102 LPCSTR src,
103 DWORD nField,
104 LPSTR dst,
105 DWORD len)
107 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src),nField,dst,len);
109 if (!src || !src[0] || !dst || !len)
110 return 0;
112 /* skip n fields delimited by ',' */
113 while (nField > 1)
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 */
123 *dst=0x0;
125 return TRUE;
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)
140 return 0;
142 /* skip n fields delimited by ',' */
143 while (nField > 1)
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 */
153 *dst = 0x0;
155 return TRUE;
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(
173 HWND hwndOwner,
174 LPSTR lpstrFile,
175 DWORD nMaxFile,
176 LPCSTR lpstrInitialDir,
177 LPCSTR lpstrDefExt,
178 LPCSTR lpstrFilter,
179 LPCSTR lpstrTitle)
181 HMODULE hmodule;
182 FARPROC pGetOpenFileNameA;
183 OPENFILENAMEA ofn;
184 BOOL ret;
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);
196 return FALSE;
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);
213 return ret;
216 /*************************************************************************
217 * SHGetSetSettings [SHELL32.68]
219 VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
221 if(bSet)
223 FIXME("%p 0x%08x TRUE\n", lpss, dwMask);
225 else
227 SHGetSettings((LPSHELLFLAGSTATE)lpss,dwMask);
231 /*************************************************************************
232 * SHGetSettings [SHELL32.@]
234 * NOTES
235 * the registry path are for win98 (tested)
236 * and possibly are the same in nt40
239 VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask)
241 HKEY hKey;
242 DWORD dwData;
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))
249 return;
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))
270 { if (dwData == 0)
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;
283 RegCloseKey (hKey);
285 TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
288 /*************************************************************************
289 * SHShellFolderView_Message [SHELL32.73]
291 * Send a message to an explorer cabinet window.
293 * PARAMS
294 * hwndCabinet [I] The window containing the shellview to communicate with
295 * dwMessage [I] The SFVM message to send
296 * dwParam [I] Message parameter
298 * RETURNS
299 * fixme.
301 * NOTES
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
306 * that was clicked.
308 LRESULT WINAPI SHShellFolderView_Message(
309 HWND hwndCabinet,
310 UINT uMessage,
311 LPARAM lParam)
313 FIXME("%p %08x %08lx stub\n",hwndCabinet, uMessage, lParam);
314 return 0;
317 /*************************************************************************
318 * RegisterShellHook [SHELL32.181]
320 * Register a shell hook.
322 * PARAMS
323 * hwnd [I] Window handle
324 * dwType [I] Type of hook.
326 * NOTES
327 * Exported by ordinal
329 BOOL WINAPI RegisterShellHook(
330 HWND hWnd,
331 DWORD dwType)
333 FIXME("(%p,0x%08x):stub.\n",hWnd, dwType);
334 return TRUE;
337 /*************************************************************************
338 * ShellMessageBoxW [SHELL32.182]
340 * See ShellMessageBoxA.
342 * NOTE:
343 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
344 * because we can't forward to it in the .spec file since it's exported by
345 * ordinal. If you change the implementation here please update the code in
346 * shlwapi as well.
348 int WINAPIV ShellMessageBoxW(
349 HINSTANCE hInstance,
350 HWND hWnd,
351 LPCWSTR lpText,
352 LPCWSTR lpCaption,
353 UINT uType,
354 ...)
356 WCHAR szText[100],szTitle[100];
357 LPCWSTR pszText = szText, pszTitle = szTitle;
358 LPWSTR pszTemp;
359 __ms_va_list args;
360 int ret;
362 __ms_va_start(args, uType);
363 /* wvsprintfA(buf,fmt, args); */
365 TRACE("(%p,%p,%p,%p,%08x)\n",
366 hInstance,hWnd,lpText,lpCaption,uType);
368 if (IS_INTRESOURCE(lpCaption))
369 LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
370 else
371 pszTitle = lpCaption;
373 if (IS_INTRESOURCE(lpText))
374 LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
375 else
376 pszText = lpText;
378 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
379 pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
381 __ms_va_end(args);
383 ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
384 LocalFree((HLOCAL)pszTemp);
385 return ret;
388 /*************************************************************************
389 * ShellMessageBoxA [SHELL32.183]
391 * Format and output an error message.
393 * PARAMS
394 * hInstance [I] Instance handle of message creator
395 * hWnd [I] Window handle of message creator
396 * lpText [I] Resource Id of title or LPSTR
397 * lpCaption [I] Resource Id of title or LPSTR
398 * uType [I] Type of error message
400 * RETURNS
401 * A return value from MessageBoxA().
403 * NOTES
404 * Exported by ordinal
406 int WINAPIV ShellMessageBoxA(
407 HINSTANCE hInstance,
408 HWND hWnd,
409 LPCSTR lpText,
410 LPCSTR lpCaption,
411 UINT uType,
412 ...)
414 char szText[100],szTitle[100];
415 LPCSTR pszText = szText, pszTitle = szTitle;
416 LPSTR pszTemp;
417 __ms_va_list args;
418 int ret;
420 __ms_va_start(args, uType);
421 /* wvsprintfA(buf,fmt, args); */
423 TRACE("(%p,%p,%p,%p,%08x)\n",
424 hInstance,hWnd,lpText,lpCaption,uType);
426 if (IS_INTRESOURCE(lpCaption))
427 LoadStringA(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle));
428 else
429 pszTitle = lpCaption;
431 if (IS_INTRESOURCE(lpText))
432 LoadStringA(hInstance, LOWORD(lpText), szText, sizeof(szText));
433 else
434 pszText = lpText;
436 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
437 pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
439 __ms_va_end(args);
441 ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
442 LocalFree((HLOCAL)pszTemp);
443 return ret;
446 /*************************************************************************
447 * SHRegisterDragDrop [SHELL32.86]
449 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
450 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
451 * for details. Under Windows 98 this function initializes the true OLE when called
452 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
454 * We follow Windows 98 behaviour.
456 * NOTES
457 * exported by ordinal
459 * SEE ALSO
460 * RegisterDragDrop, SHLoadOLE
462 HRESULT WINAPI SHRegisterDragDrop(
463 HWND hWnd,
464 LPDROPTARGET pDropTarget)
466 static BOOL ole_initialized = FALSE;
467 HRESULT hr;
469 TRACE("(%p,%p)\n", hWnd, pDropTarget);
471 if (!ole_initialized)
473 hr = OleInitialize(NULL);
474 if (FAILED(hr))
475 return hr;
476 ole_initialized = TRUE;
478 return RegisterDragDrop(hWnd, pDropTarget);
481 /*************************************************************************
482 * SHRevokeDragDrop [SHELL32.87]
484 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
485 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
486 * for details. Function removed from Windows Vista.
488 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
489 * not called.
491 * NOTES
492 * exported by ordinal
494 * SEE ALSO
495 * RevokeDragDrop, SHLoadOLE
497 HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
499 TRACE("(%p)\n", hWnd);
500 return RevokeDragDrop(hWnd);
503 /*************************************************************************
504 * SHDoDragDrop [SHELL32.88]
506 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
507 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
508 * for details
510 * NOTES
511 * exported by ordinal
513 * SEE ALSO
514 * DoDragDrop, SHLoadOLE
516 HRESULT WINAPI SHDoDragDrop(
517 HWND hWnd,
518 LPDATAOBJECT lpDataObject,
519 LPDROPSOURCE lpDropSource,
520 DWORD dwOKEffect,
521 LPDWORD pdwEffect)
523 FIXME("(%p %p %p 0x%08x %p):stub.\n",
524 hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
525 return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
528 /*************************************************************************
529 * ArrangeWindows [SHELL32.184]
532 WORD WINAPI ArrangeWindows(
533 HWND hwndParent,
534 DWORD dwReserved,
535 LPCRECT lpRect,
536 WORD cKids,
537 CONST HWND * lpKids)
539 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
540 hwndParent, dwReserved, lpRect, cKids, lpKids);
541 return 0;
544 /*************************************************************************
545 * SignalFileOpen [SHELL32.103]
547 * NOTES
548 * exported by ordinal
550 DWORD WINAPI
551 SignalFileOpen (DWORD dwParam1)
553 FIXME("(0x%08x):stub.\n", dwParam1);
555 return 0;
558 /*************************************************************************
559 * SHADD_get_policy - helper function for SHAddToRecentDocs
561 * PARAMETERS
562 * policy [IN] policy name (null termed string) to find
563 * type [OUT] ptr to DWORD to receive type
564 * buffer [OUT] ptr to area to hold data retrieved
565 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
566 * length filled
568 * RETURNS
569 * result of the SHQueryValueEx call
571 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
573 HKEY Policy_basekey;
574 INT ret;
576 /* Get the key for the policies location in the registry
578 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
579 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
580 0, KEY_READ, &Policy_basekey)) {
582 if (RegOpenKeyExA(HKEY_CURRENT_USER,
583 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
584 0, KEY_READ, &Policy_basekey)) {
585 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
586 policy);
587 *len = 0;
588 return ERROR_FILE_NOT_FOUND;
592 /* Retrieve the data if it exists
594 ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len);
595 RegCloseKey(Policy_basekey);
596 return ret;
600 /*************************************************************************
601 * SHADD_compare_mru - helper function for SHAddToRecentDocs
603 * PARAMETERS
604 * data1 [IN] data being looked for
605 * data2 [IN] data in MRU
606 * cbdata [IN] length from FindMRUData call (not used)
608 * RETURNS
609 * position within MRU list that data was added.
611 static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData)
613 return lstrcmpiA(data1, data2);
616 /*************************************************************************
617 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
619 * PARAMETERS
620 * mruhandle [IN] handle for created MRU list
621 * doc_name [IN] null termed pure doc name
622 * new_lnk_name [IN] null termed path and file name for .lnk file
623 * buffer [IN/OUT] 2048 byte area to construct MRU data
624 * len [OUT] ptr to int to receive space used in buffer
626 * RETURNS
627 * position within MRU list that data was added.
629 static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPCSTR doc_name, LPCSTR new_lnk_name,
630 LPSTR buffer, INT *len)
632 LPSTR ptr;
633 INT wlen;
635 /*FIXME: Document:
636 * RecentDocs MRU data structure seems to be:
637 * +0h document file name w/ terminating 0h
638 * +nh short int w/ size of remaining
639 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
640 * +n+4h 10 bytes zeros - unknown
641 * +n+eh shortcut file name w/ terminating 0h
642 * +n+e+nh 3 zero bytes - unknown
645 /* Create the MRU data structure for "RecentDocs"
647 ptr = buffer;
648 lstrcpyA(ptr, doc_name);
649 ptr += (lstrlenA(buffer) + 1);
650 wlen= lstrlenA(new_lnk_name) + 1 + 12;
651 *((short int*)ptr) = wlen;
652 ptr += 2; /* step past the length */
653 *(ptr++) = 0x30; /* unknown reason */
654 *(ptr++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
655 memset(ptr, 0, 10);
656 ptr += 10;
657 lstrcpyA(ptr, new_lnk_name);
658 ptr += (lstrlenA(new_lnk_name) + 1);
659 memset(ptr, 0, 3);
660 ptr += 3;
661 *len = ptr - buffer;
663 /* Add the new entry into the MRU list
665 return AddMRUData(mruhandle, (LPCVOID)buffer, *len);
668 /*************************************************************************
669 * SHAddToRecentDocs [SHELL32.@]
671 * Modify (add/clear) Shell's list of recently used documents.
673 * PARAMETERS
674 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
675 * pv [IN] string or pidl, NULL clears the list
677 * NOTES
678 * exported by name
680 * FIXME
681 * convert to unicode
683 void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
685 /* If list is a string list lpfnCompare has the following prototype
686 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
687 * for binary lists the prototype is
688 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
689 * where cbData is the no. of bytes to compare.
690 * Need to check what return value means identical - 0?
694 UINT olderrormode;
695 HKEY HCUbasekey;
696 CHAR doc_name[MAX_PATH];
697 CHAR link_dir[MAX_PATH];
698 CHAR new_lnk_filepath[MAX_PATH];
699 CHAR new_lnk_name[MAX_PATH];
700 IMalloc *ppM;
701 LPITEMIDLIST pidl;
702 HWND hwnd = 0; /* FIXME: get real window handle */
703 INT ret;
704 DWORD data[64], datalen, type;
706 TRACE("%04x %p\n", uFlags, pv);
708 /*FIXME: Document:
709 * RecentDocs MRU data structure seems to be:
710 * +0h document file name w/ terminating 0h
711 * +nh short int w/ size of remaining
712 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
713 * +n+4h 10 bytes zeros - unknown
714 * +n+eh shortcut file name w/ terminating 0h
715 * +n+e+nh 3 zero bytes - unknown
718 /* See if we need to do anything.
720 datalen = 64;
721 ret=SHADD_get_policy( "NoRecentDocsHistory", &type, data, &datalen);
722 if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) {
723 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret);
724 return;
726 if (ret == ERROR_SUCCESS) {
727 if (!( (type == REG_DWORD) ||
728 ((type == REG_BINARY) && (datalen == 4)) )) {
729 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
730 type, datalen);
731 return;
734 TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
735 /* now test the actual policy value */
736 if ( data[0] != 0)
737 return;
740 /* Open key to where the necessary info is
742 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
743 * and the close should be done during the _DETACH. The resulting
744 * key is stored in the DLL global data.
746 if (RegCreateKeyExA(HKEY_CURRENT_USER,
747 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
748 0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
749 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
750 return;
753 /* Get path to user's "Recent" directory
755 if(SUCCEEDED(SHGetMalloc(&ppM))) {
756 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
757 &pidl))) {
758 SHGetPathFromIDListA(pidl, link_dir);
759 IMalloc_Free(ppM, pidl);
761 else {
762 /* serious issues */
763 link_dir[0] = 0;
764 ERR("serious issues 1\n");
766 IMalloc_Release(ppM);
768 else {
769 /* serious issues */
770 link_dir[0] = 0;
771 ERR("serious issues 2\n");
773 TRACE("Users Recent dir %s\n", link_dir);
775 /* If no input, then go clear the lists */
776 if (!pv) {
777 /* clear user's Recent dir
780 /* FIXME: delete all files in "link_dir"
782 * while( more files ) {
783 * lstrcpyA(old_lnk_name, link_dir);
784 * PathAppendA(old_lnk_name, filenam);
785 * DeleteFileA(old_lnk_name);
788 FIXME("should delete all files in %s\\\n", link_dir);
790 /* clear MRU list
792 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
793 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
794 * and naturally it fails w/ rc=2. It should do it against
795 * HKEY_CURRENT_USER which is where it is stored, and where
796 * the MRU routines expect it!!!!
798 RegDeleteKeyA(HCUbasekey, "RecentDocs");
799 RegCloseKey(HCUbasekey);
800 return;
803 /* Have data to add, the jobs to be done:
804 * 1. Add document to MRU list in registry "HKCU\Software\
805 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
806 * 2. Add shortcut to document in the user's Recent directory
807 * (CSIDL_RECENT).
808 * 3. Add shortcut to Start menu's Documents submenu.
811 /* Get the pure document name from the input
813 switch (uFlags)
815 case SHARD_PIDL:
816 SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name);
817 break;
819 case SHARD_PATHA:
820 lstrcpynA(doc_name, (LPCSTR)pv, MAX_PATH);
821 break;
823 case SHARD_PATHW:
824 WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pv, -1, doc_name, MAX_PATH, NULL, NULL);
825 break;
827 default:
828 FIXME("Unsupported flags: %u\n", uFlags);
829 return;
832 TRACE("full document name %s\n", debugstr_a(doc_name));
833 PathStripPathA(doc_name);
834 TRACE("stripped document name %s\n", debugstr_a(doc_name));
837 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
839 { /* on input needs:
840 * doc_name - pure file-spec, no path
841 * link_dir - path to the user's Recent directory
842 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
843 * creates:
844 * new_lnk_name- pure file-spec, no path for new .lnk file
845 * new_lnk_filepath
846 * - path and file name of new .lnk file
848 CREATEMRULISTA mymru;
849 HANDLE mruhandle;
850 INT len, pos, bufused, err;
851 INT i;
852 DWORD attr;
853 CHAR buffer[2048];
854 CHAR *ptr;
855 CHAR old_lnk_name[MAX_PATH];
856 short int slen;
858 mymru.cbSize = sizeof(CREATEMRULISTA);
859 mymru.nMaxItems = 15;
860 mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE;
861 mymru.hKey = HCUbasekey;
862 mymru.lpszSubKey = "RecentDocs";
863 mymru.lpfnCompare = (PROC)SHADD_compare_mru;
864 mruhandle = CreateMRUListA(&mymru);
865 if (!mruhandle) {
866 /* MRU failed */
867 ERR("MRU processing failed, handle zero\n");
868 RegCloseKey(HCUbasekey);
869 return;
871 len = lstrlenA(doc_name);
872 pos = FindMRUData(mruhandle, doc_name, len, 0);
874 /* Now get the MRU entry that will be replaced
875 * and delete the .lnk file for it
877 if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos,
878 buffer, 2048)) != -1) {
879 ptr = buffer;
880 ptr += (lstrlenA(buffer) + 1);
881 slen = *((short int*)ptr);
882 ptr += 2; /* skip the length area */
883 if (bufused >= slen + (ptr-buffer)) {
884 /* buffer size looks good */
885 ptr += 12; /* get to string */
886 len = bufused - (ptr-buffer); /* get length of buf remaining */
887 if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
888 /* appears to be good string */
889 lstrcpyA(old_lnk_name, link_dir);
890 PathAppendA(old_lnk_name, ptr);
891 if (!DeleteFileA(old_lnk_name)) {
892 if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
893 if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
894 ERR("Delete for %s failed, err=%d, attr=%08x\n",
895 old_lnk_name, err, attr);
897 else {
898 TRACE("old .lnk file %s did not exist\n",
899 old_lnk_name);
902 else {
903 ERR("Delete for %s failed, attr=%08x\n",
904 old_lnk_name, attr);
907 else {
908 TRACE("deleted old .lnk file %s\n", old_lnk_name);
914 /* Create usable .lnk file name for the "Recent" directory
916 wsprintfA(new_lnk_name, "%s.lnk", doc_name);
917 lstrcpyA(new_lnk_filepath, link_dir);
918 PathAppendA(new_lnk_filepath, new_lnk_name);
919 i = 1;
920 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
921 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
922 i++;
923 wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
924 lstrcpyA(new_lnk_filepath, link_dir);
925 PathAppendA(new_lnk_filepath, new_lnk_name);
927 SetErrorMode(olderrormode);
928 TRACE("new shortcut will be %s\n", new_lnk_filepath);
930 /* Now add the new MRU entry and data
932 pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name,
933 buffer, &len);
934 FreeMRUList(mruhandle);
935 TRACE("Updated MRU list, new doc is position %d\n", pos);
938 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
940 { /* on input needs:
941 * doc_name - pure file-spec, no path
942 * new_lnk_filepath
943 * - path and file name of new .lnk file
944 * uFlags[in] - flags on call to SHAddToRecentDocs
945 * pv[in] - document path/pidl on call to SHAddToRecentDocs
947 IShellLinkA *psl = NULL;
948 IPersistFile *pPf = NULL;
949 HRESULT hres;
950 CHAR desc[MAX_PATH];
951 WCHAR widelink[MAX_PATH];
953 CoInitialize(0);
955 hres = CoCreateInstance( &CLSID_ShellLink,
956 NULL,
957 CLSCTX_INPROC_SERVER,
958 &IID_IShellLinkA,
959 (LPVOID )&psl);
960 if(SUCCEEDED(hres)) {
962 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
963 (LPVOID *)&pPf);
964 if(FAILED(hres)) {
965 /* bombed */
966 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
967 goto fail;
970 /* Set the document path or pidl */
971 if (uFlags == SHARD_PIDL) {
972 hres = IShellLinkA_SetIDList(psl, (LPCITEMIDLIST) pv);
973 } else {
974 hres = IShellLinkA_SetPath(psl, (LPCSTR) pv);
976 if(FAILED(hres)) {
977 /* bombed */
978 ERR("failed Set{IDList|Path} %08x\n", hres);
979 goto fail;
982 lstrcpyA(desc, "Shortcut to ");
983 lstrcatA(desc, doc_name);
984 hres = IShellLinkA_SetDescription(psl, desc);
985 if(FAILED(hres)) {
986 /* bombed */
987 ERR("failed SetDescription %08x\n", hres);
988 goto fail;
991 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
992 widelink, MAX_PATH);
993 /* create the short cut */
994 hres = IPersistFile_Save(pPf, widelink, TRUE);
995 if(FAILED(hres)) {
996 /* bombed */
997 ERR("failed IPersistFile::Save %08x\n", hres);
998 IPersistFile_Release(pPf);
999 IShellLinkA_Release(psl);
1000 goto fail;
1002 hres = IPersistFile_SaveCompleted(pPf, widelink);
1003 IPersistFile_Release(pPf);
1004 IShellLinkA_Release(psl);
1005 TRACE("shortcut %s has been created, result=%08x\n",
1006 new_lnk_filepath, hres);
1008 else {
1009 ERR("CoCreateInstance failed, hres=%08x\n", hres);
1013 fail:
1014 CoUninitialize();
1016 /* all done */
1017 RegCloseKey(HCUbasekey);
1018 return;
1021 /*************************************************************************
1022 * SHCreateShellFolderViewEx [SHELL32.174]
1024 * Create a new instance of the default Shell folder view object.
1026 * RETURNS
1027 * Success: S_OK
1028 * Failure: error value
1030 * NOTES
1031 * see IShellFolder::CreateViewObject
1033 HRESULT WINAPI SHCreateShellFolderViewEx(
1034 LPCSFV psvcbi, /* [in] shelltemplate struct */
1035 IShellView **ppv) /* [out] IShellView pointer */
1037 IShellView * psf;
1038 HRESULT hRes;
1040 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1041 psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
1042 psvcbi->fvm, psvcbi->psvOuter);
1044 psf = IShellView_Constructor(psvcbi->pshf);
1046 if (!psf)
1047 return E_OUTOFMEMORY;
1049 IShellView_AddRef(psf);
1050 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1051 IShellView_Release(psf);
1053 return hRes;
1055 /*************************************************************************
1056 * SHWinHelp [SHELL32.127]
1059 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
1060 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v,w,x,z);
1061 return 0;
1063 /*************************************************************************
1064 * SHRunControlPanel [SHELL32.161]
1067 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
1068 { FIXME("0x%08x 0x%08x stub\n",x,z);
1069 return 0;
1072 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1073 /*************************************************************************
1074 * SHSetInstanceExplorer [SHELL32.176]
1076 * NOTES
1077 * Sets the interface
1079 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1080 { TRACE("%p\n", lpUnknown);
1081 SHELL32_IExplorerInterface = lpUnknown;
1083 /*************************************************************************
1084 * SHGetInstanceExplorer [SHELL32.@]
1086 * NOTES
1087 * gets the interface pointer of the explorer and a reference
1089 HRESULT WINAPI SHGetInstanceExplorer (IUnknown **lpUnknown)
1090 { TRACE("%p\n", lpUnknown);
1092 *lpUnknown = SHELL32_IExplorerInterface;
1094 if (!SHELL32_IExplorerInterface)
1095 return E_FAIL;
1097 IUnknown_AddRef(SHELL32_IExplorerInterface);
1098 return NOERROR;
1100 /*************************************************************************
1101 * SHFreeUnusedLibraries [SHELL32.123]
1103 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1104 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1105 * for details
1107 * NOTES
1108 * exported by ordinal
1110 * SEE ALSO
1111 * CoFreeUnusedLibraries, SHLoadOLE
1113 void WINAPI SHFreeUnusedLibraries (void)
1115 FIXME("stub\n");
1116 CoFreeUnusedLibraries();
1118 /*************************************************************************
1119 * DAD_AutoScroll [SHELL32.129]
1122 BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, LPPOINT pt)
1124 FIXME("hwnd = %p %p %p\n",hwnd,samples,pt);
1125 return 0;
1127 /*************************************************************************
1128 * DAD_DragEnter [SHELL32.130]
1131 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1133 FIXME("hwnd = %p\n",hwnd);
1134 return FALSE;
1136 /*************************************************************************
1137 * DAD_DragEnterEx [SHELL32.131]
1140 BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p)
1142 FIXME("hwnd = %p (%d,%d)\n",hwnd,p.x,p.y);
1143 return FALSE;
1145 /*************************************************************************
1146 * DAD_DragMove [SHELL32.134]
1149 BOOL WINAPI DAD_DragMove(POINT p)
1151 FIXME("(%d,%d)\n",p.x,p.y);
1152 return FALSE;
1154 /*************************************************************************
1155 * DAD_DragLeave [SHELL32.132]
1158 BOOL WINAPI DAD_DragLeave(VOID)
1160 FIXME("\n");
1161 return FALSE;
1163 /*************************************************************************
1164 * DAD_SetDragImage [SHELL32.136]
1166 * NOTES
1167 * exported by name
1169 BOOL WINAPI DAD_SetDragImage(
1170 HIMAGELIST himlTrack,
1171 LPPOINT lppt)
1173 FIXME("%p %p stub\n",himlTrack, lppt);
1174 return 0;
1176 /*************************************************************************
1177 * DAD_ShowDragImage [SHELL32.137]
1179 * NOTES
1180 * exported by name
1182 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1184 FIXME("0x%08x stub\n",bShow);
1185 return 0;
1188 static const WCHAR szwCabLocation[] = {
1189 'S','o','f','t','w','a','r','e','\\',
1190 'M','i','c','r','o','s','o','f','t','\\',
1191 'W','i','n','d','o','w','s','\\',
1192 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1193 'E','x','p','l','o','r','e','r','\\',
1194 'C','a','b','i','n','e','t','S','t','a','t','e',0
1197 static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 };
1199 /*************************************************************************
1200 * ReadCabinetState [SHELL32.651] NT 4.0
1203 BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
1205 HKEY hkey = 0;
1206 DWORD type, r;
1208 TRACE("%p %d\n", cs, length);
1210 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1211 return FALSE;
1213 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1214 if( r == ERROR_SUCCESS )
1216 type = REG_BINARY;
1217 r = RegQueryValueExW( hkey, szwSettings,
1218 NULL, &type, (LPBYTE)cs, (LPDWORD)&length );
1219 RegCloseKey( hkey );
1223 /* if we can't read from the registry, create default values */
1224 if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) ||
1225 (cs->cLength != length) )
1227 ERR("Initializing shell cabinet settings\n");
1228 memset(cs, 0, sizeof(*cs));
1229 cs->cLength = sizeof(*cs);
1230 cs->nVersion = 2;
1231 cs->fFullPathTitle = FALSE;
1232 cs->fSaveLocalView = TRUE;
1233 cs->fNotShell = FALSE;
1234 cs->fSimpleDefault = TRUE;
1235 cs->fDontShowDescBar = FALSE;
1236 cs->fNewWindowMode = FALSE;
1237 cs->fShowCompColor = FALSE;
1238 cs->fDontPrettyNames = FALSE;
1239 cs->fAdminsCreateCommonGroups = TRUE;
1240 cs->fMenuEnumFilter = 96;
1243 return TRUE;
1246 /*************************************************************************
1247 * WriteCabinetState [SHELL32.652] NT 4.0
1250 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1252 DWORD r;
1253 HKEY hkey = 0;
1255 TRACE("%p\n",cs);
1257 if( cs == NULL )
1258 return FALSE;
1260 r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0,
1261 NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
1262 if( r == ERROR_SUCCESS )
1264 r = RegSetValueExW( hkey, szwSettings, 0,
1265 REG_BINARY, (LPBYTE) cs, cs->cLength);
1267 RegCloseKey( hkey );
1270 return (r==ERROR_SUCCESS);
1273 /*************************************************************************
1274 * FileIconInit [SHELL32.660]
1277 BOOL WINAPI FileIconInit(BOOL bFullInit)
1278 { FIXME("(%s)\n", bFullInit ? "true" : "false");
1279 return 0;
1281 /*************************************************************************
1282 * IsUserAdmin [SHELL32.680] NT 4.0
1285 HRESULT WINAPI IsUserAdmin(void)
1286 { FIXME("stub\n");
1287 return TRUE;
1290 /*************************************************************************
1291 * SHAllocShared [SHELL32.520]
1293 * See shlwapi.SHAllocShared
1295 HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
1297 GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
1298 return pSHAllocShared(lpvData, dwSize, dwProcId);
1301 /*************************************************************************
1302 * SHLockShared [SHELL32.521]
1304 * See shlwapi.SHLockShared
1306 LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
1308 GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
1309 return pSHLockShared(hShared, dwProcId);
1312 /*************************************************************************
1313 * SHUnlockShared [SHELL32.522]
1315 * See shlwapi.SHUnlockShared
1317 BOOL WINAPI SHUnlockShared(LPVOID lpView)
1319 GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
1320 return pSHUnlockShared(lpView);
1323 /*************************************************************************
1324 * SHFreeShared [SHELL32.523]
1326 * See shlwapi.SHFreeShared
1328 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
1330 GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
1331 return pSHFreeShared(hShared, dwProcId);
1334 /*************************************************************************
1335 * SetAppStartingCursor [SHELL32.99]
1337 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1338 { FIXME("hwnd=%p 0x%04x stub\n",u,v );
1339 return 0;
1342 /*************************************************************************
1343 * SHLoadOLE [SHELL32.151]
1345 * To reduce the memory usage of Windows 95, its shell32 contained an
1346 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1347 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1348 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1349 * would just call the Co* functions.
1351 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1352 * information from the shell32 "mini-COM" to ole32.dll.
1354 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1355 * detailed description.
1357 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1358 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1359 * hack in SHCoCreateInstance)
1361 HRESULT WINAPI SHLoadOLE(LPARAM lParam)
1362 { FIXME("0x%08lx stub\n",lParam);
1363 return S_OK;
1365 /*************************************************************************
1366 * DriveType [SHELL32.64]
1369 HRESULT WINAPI DriveType(DWORD u)
1370 { FIXME("0x%04x stub\n",u);
1371 return 0;
1373 /*************************************************************************
1374 * InvalidateDriveType [SHELL32.65]
1377 int WINAPI InvalidateDriveType(int u)
1378 { FIXME("0x%08x stub\n",u);
1379 return 0;
1381 /*************************************************************************
1382 * SHAbortInvokeCommand [SHELL32.198]
1385 HRESULT WINAPI SHAbortInvokeCommand(void)
1386 { FIXME("stub\n");
1387 return 1;
1389 /*************************************************************************
1390 * SHOutOfMemoryMessageBox [SHELL32.126]
1393 int WINAPI SHOutOfMemoryMessageBox(
1394 HWND hwndOwner,
1395 LPCSTR lpCaption,
1396 UINT uType)
1398 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1399 return 0;
1401 /*************************************************************************
1402 * SHFlushClipboard [SHELL32.121]
1405 HRESULT WINAPI SHFlushClipboard(void)
1406 { FIXME("stub\n");
1407 return 1;
1410 /*************************************************************************
1411 * SHWaitForFileToOpen [SHELL32.97]
1414 BOOL WINAPI SHWaitForFileToOpen(
1415 LPCITEMIDLIST pidl,
1416 DWORD dwFlags,
1417 DWORD dwTimeout)
1419 FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1420 return 0;
1423 /************************************************************************
1424 * @ [SHELL32.654]
1426 * NOTES
1427 * first parameter seems to be a pointer (same as passed to WriteCabinetState)
1428 * second one could be a size (0x0c). The size is the same as the structure saved to
1429 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1430 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1432 HRESULT WINAPI shell32_654 (CABINETSTATE *cs, int length)
1434 TRACE("%p %d\n",cs,length);
1435 return ReadCabinetState(cs,length);
1438 /************************************************************************
1439 * RLBuildListOfPaths [SHELL32.146]
1441 * NOTES
1442 * builds a DPA
1444 DWORD WINAPI RLBuildListOfPaths (void)
1445 { FIXME("stub\n");
1446 return 0;
1448 /************************************************************************
1449 * SHValidateUNC [SHELL32.173]
1452 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1454 FIXME("0x%08x 0x%08x 0x%08x stub\n",x,y,z);
1455 return 0;
1458 /************************************************************************
1459 * DoEnvironmentSubstA [SHELL32.@]
1461 * Replace %KEYWORD% in the str with the value of variable KEYWORD
1462 * from environment. If it is not found the %KEYWORD% is left
1463 * intact. If the buffer is too small, str is not modified.
1465 * PARAMS
1466 * pszString [I] '\0' terminated string with %keyword%.
1467 * [O] '\0' terminated string with %keyword% substituted.
1468 * cchString [I] size of str.
1470 * RETURNS
1471 * cchString length in the HIWORD;
1472 * TRUE in LOWORD if subst was successful and FALSE in other case
1474 DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
1476 LPSTR dst;
1477 BOOL res = FALSE;
1478 FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
1479 if (pszString == NULL) /* Really return 0? */
1480 return 0;
1481 if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
1483 DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
1484 if (num && num < cchString) /* dest buffer is too small */
1486 res = TRUE;
1487 memcpy(pszString, dst, num);
1489 HeapFree(GetProcessHeap(), 0, dst);
1491 return MAKELONG(res,cchString); /* Always cchString? */
1494 /************************************************************************
1495 * DoEnvironmentSubstW [SHELL32.@]
1497 * See DoEnvironmentSubstA.
1499 DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
1501 FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
1502 return MAKELONG(FALSE,cchString);
1505 /************************************************************************
1506 * DoEnvironmentSubst [SHELL32.53]
1508 * See DoEnvironmentSubstA.
1510 DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y)
1512 if (SHELL_OsIsUnicode())
1513 return DoEnvironmentSubstW(x, y);
1514 return DoEnvironmentSubstA(x, y);
1517 /*************************************************************************
1518 * @ [SHELL32.243]
1520 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1521 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1525 BOOL WINAPI shell32_243(DWORD a, DWORD b)
1527 return FALSE;
1530 /*************************************************************************
1531 * @ [SHELL32.714]
1533 DWORD WINAPI SHELL32_714(LPVOID x)
1535 FIXME("(%s)stub\n", debugstr_w(x));
1536 return 0;
1539 typedef struct _PSXA
1541 UINT uiCount;
1542 UINT uiAllocated;
1543 IShellPropSheetExt *pspsx[1];
1544 } PSXA, *PPSXA;
1546 typedef struct _PSXA_CALL
1548 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith;
1549 LPARAM lParam;
1550 BOOL bCalled;
1551 BOOL bMultiple;
1552 UINT uiCount;
1553 } PSXA_CALL, *PPSXA_CALL;
1555 static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam)
1557 PPSXA_CALL Call = (PPSXA_CALL)lParam;
1559 if (Call != NULL)
1561 if ((Call->bMultiple || !Call->bCalled) &&
1562 Call->lpfnAddReplaceWith(hpage, Call->lParam))
1564 Call->bCalled = TRUE;
1565 Call->uiCount++;
1566 return TRUE;
1570 return FALSE;
1573 /*************************************************************************
1574 * SHAddFromPropSheetExtArray [SHELL32.167]
1576 UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
1578 PSXA_CALL Call;
1579 UINT i;
1580 PPSXA psxa = (PPSXA)hpsxa;
1582 TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam);
1584 if (psxa)
1586 ZeroMemory(&Call, sizeof(Call));
1587 Call.lpfnAddReplaceWith = lpfnAddPage;
1588 Call.lParam = lParam;
1589 Call.bMultiple = TRUE;
1591 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1592 for (i = 0; i != psxa->uiCount; i++)
1594 psxa->pspsx[i]->lpVtbl->AddPages(psxa->pspsx[i], PsxaCall, (LPARAM)&Call);
1597 return Call.uiCount;
1600 return 0;
1603 /*************************************************************************
1604 * SHCreatePropSheetExtArray [SHELL32.168]
1606 HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
1608 return SHCreatePropSheetExtArrayEx(hKey, pszSubKey, max_iface, NULL);
1611 /*************************************************************************
1612 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1614 HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, LPDATAOBJECT pDataObj)
1616 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};
1617 WCHAR szHandler[64];
1618 DWORD dwHandlerLen;
1619 WCHAR szClsidHandler[39];
1620 DWORD dwClsidSize;
1621 CLSID clsid;
1622 LONG lRet;
1623 DWORD dwIndex;
1624 IShellExtInit *psxi;
1625 IShellPropSheetExt *pspsx;
1626 HKEY hkBase, hkPropSheetHandlers;
1627 PPSXA psxa = NULL;
1629 TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface);
1631 if (max_iface == 0)
1632 return NULL;
1634 /* Open the registry key */
1635 lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase);
1636 if (lRet != ERROR_SUCCESS)
1637 return NULL;
1639 lRet = RegOpenKeyExW(hkBase, szPropSheetSubKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkPropSheetHandlers);
1640 RegCloseKey(hkBase);
1641 if (lRet == ERROR_SUCCESS)
1643 /* Create and initialize the Property Sheet Extensions Array */
1644 psxa = LocalAlloc(LMEM_FIXED, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1645 if (psxa)
1647 ZeroMemory(psxa, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1648 psxa->uiAllocated = max_iface;
1650 /* Enumerate all subkeys and attempt to load the shell extensions */
1651 dwIndex = 0;
1654 dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]);
1655 lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL);
1656 if (lRet != ERROR_SUCCESS)
1658 if (lRet == ERROR_MORE_DATA)
1659 continue;
1661 if (lRet == ERROR_NO_MORE_ITEMS)
1662 lRet = ERROR_SUCCESS;
1663 break;
1666 dwClsidSize = sizeof(szClsidHandler);
1667 if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
1669 /* Force a NULL-termination and convert the string */
1670 szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
1671 if (SUCCEEDED(SHCLSIDFromStringW(szClsidHandler, &clsid)))
1673 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1674 Only if both interfaces are supported it's a real shell extension.
1675 Then call IShellExtInit's Initialize method. */
1676 if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx)))
1678 if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi)))
1680 if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey)))
1682 /* Add the IShellPropSheetExt instance to the array */
1683 psxa->pspsx[psxa->uiCount++] = pspsx;
1685 else
1687 psxi->lpVtbl->Release(psxi);
1688 pspsx->lpVtbl->Release(pspsx);
1691 else
1692 pspsx->lpVtbl->Release(pspsx);
1697 } while (psxa->uiCount != psxa->uiAllocated);
1699 else
1700 lRet = ERROR_NOT_ENOUGH_MEMORY;
1702 RegCloseKey(hkPropSheetHandlers);
1705 if (lRet != ERROR_SUCCESS && psxa)
1707 SHDestroyPropSheetExtArray((HPSXA)psxa);
1708 psxa = NULL;
1711 return (HPSXA)psxa;
1714 /*************************************************************************
1715 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1717 UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
1719 PSXA_CALL Call;
1720 UINT i;
1721 PPSXA psxa = (PPSXA)hpsxa;
1723 TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam);
1725 if (psxa)
1727 ZeroMemory(&Call, sizeof(Call));
1728 Call.lpfnAddReplaceWith = lpfnReplaceWith;
1729 Call.lParam = lParam;
1731 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1732 Each shell extension is only allowed to call the callback once during the callback. */
1733 for (i = 0; i != psxa->uiCount; i++)
1735 Call.bCalled = FALSE;
1736 psxa->pspsx[i]->lpVtbl->ReplacePage(psxa->pspsx[i], uPageID, PsxaCall, (LPARAM)&Call);
1739 return Call.uiCount;
1742 return 0;
1745 /*************************************************************************
1746 * SHDestroyPropSheetExtArray [SHELL32.169]
1748 void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
1750 UINT i;
1751 PPSXA psxa = (PPSXA)hpsxa;
1753 TRACE("(%p)\n", hpsxa);
1755 if (psxa)
1757 for (i = 0; i != psxa->uiCount; i++)
1759 psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]);
1762 LocalFree((HLOCAL)psxa);
1766 /*************************************************************************
1767 * CIDLData_CreateFromIDArray [SHELL32.83]
1769 * Create IDataObject from PIDLs??
1771 HRESULT WINAPI CIDLData_CreateFromIDArray(
1772 LPCITEMIDLIST pidlFolder,
1773 DWORD cpidlFiles,
1774 LPCITEMIDLIST *lppidlFiles,
1775 LPDATAOBJECT *ppdataObject)
1777 UINT i;
1778 HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */
1780 TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1781 if (TRACE_ON(pidl))
1783 pdump (pidlFolder);
1784 for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1786 *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1787 lppidlFiles, cpidlFiles);
1788 if (*ppdataObject) return S_OK;
1789 return E_OUTOFMEMORY;
1792 /*************************************************************************
1793 * SHCreateStdEnumFmtEtc [SHELL32.74]
1795 * NOTES
1798 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1799 DWORD cFormats,
1800 const FORMATETC *lpFormats,
1801 LPENUMFORMATETC *ppenumFormatetc)
1803 IEnumFORMATETC *pef;
1804 HRESULT hRes;
1805 TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1807 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1808 if (!pef)
1809 return E_OUTOFMEMORY;
1811 IEnumFORMATETC_AddRef(pef);
1812 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1813 IEnumFORMATETC_Release(pef);
1815 return hRes;
1819 /*************************************************************************
1820 * SHELL32_256 (SHELL32.256)
1822 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1824 HRESULT ret = S_OK;
1826 FIXME("stub %p 0x%08x %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1828 if (!lpdw0 || *lpdw0 != 0x10)
1829 ret = E_INVALIDARG;
1830 else
1832 LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1834 if (!lpdata)
1835 ret = E_OUTOFMEMORY;
1836 else
1838 /* Initialize and return unknown lpdata structure */
1842 return ret;
1845 /*************************************************************************
1846 * SHFindFiles (SHELL32.90)
1848 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1850 FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1851 return FALSE;
1854 /*************************************************************************
1855 * SHUpdateImageW (SHELL32.192)
1857 * Notifies the shell that an icon in the system image list has been changed.
1859 * PARAMS
1860 * pszHashItem [I] Path to file that contains the icon.
1861 * iIndex [I] Zero-based index of the icon in the file.
1862 * uFlags [I] Flags determining the icon attributes. See notes.
1863 * iImageIndex [I] Index of the icon in the system image list.
1865 * RETURNS
1866 * Nothing
1868 * NOTES
1869 * uFlags can be one or more of the following flags:
1870 * GIL_NOTFILENAME - pszHashItem is not a file name.
1871 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1873 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
1875 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
1878 /*************************************************************************
1879 * SHUpdateImageA (SHELL32.191)
1881 * See SHUpdateImageW.
1883 VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex)
1885 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex);
1888 INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra)
1890 FIXME("%p - stub\n", pidlExtra);
1892 return -1;
1895 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
1897 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
1899 return TRUE;
1902 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
1903 UINT uFlags)
1905 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo), debugstr_a(pszDir),
1906 pszName, pfMustCopy, uFlags);
1908 return FALSE;
1911 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
1912 UINT uFlags)
1914 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
1915 pszName, pfMustCopy, uFlags);
1917 return FALSE;
1920 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
1922 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
1924 return S_OK;
1927 HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
1929 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1931 return S_OK;
1934 HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
1936 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1938 return S_OK;
1941 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
1943 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
1945 return SHFMT_NOFORMAT;
1948 HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1950 FIXME("%s, %p - stub\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1952 pSHQueryRBInfo->i64Size = 0;
1953 pSHQueryRBInfo->i64NumItems = 0;
1955 return S_OK;
1958 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1960 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1962 pSHQueryRBInfo->i64Size = 0;
1963 pSHQueryRBInfo->i64NumItems = 0;
1965 return S_OK;
1968 /*************************************************************************
1969 * SHSetLocalizedName (SHELL32.@)
1971 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
1973 FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
1975 return S_OK;
1978 /*************************************************************************
1979 * LinkWindow_RegisterClass (SHELL32.258)
1981 BOOL WINAPI LinkWindow_RegisterClass(void)
1983 FIXME("()\n");
1984 return TRUE;
1987 /*************************************************************************
1988 * LinkWindow_UnregisterClass (SHELL32.259)
1990 BOOL WINAPI LinkWindow_UnregisterClass(void)
1992 FIXME("()\n");
1993 return TRUE;
1996 /*************************************************************************
1997 * (SHELL32.526)
1999 BOOL WINAPI SHELL32_526(void)
2001 FIXME("()\n");
2002 return FALSE;