d3d: Remove AddRef from IWineD3DDevice_GetDepthStencilSurface.
[wine.git] / dlls / shell32 / shellord.c
blobef6b7b8c431ddeb06b0c70b55a5a2193a0bc9187
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 int WINAPIV ShellMessageBoxW(
343 HINSTANCE hInstance,
344 HWND hWnd,
345 LPCWSTR lpText,
346 LPCWSTR lpCaption,
347 UINT uType,
348 ...)
350 WCHAR szText[100],szTitle[100];
351 LPCWSTR pszText = szText, pszTitle = szTitle;
352 LPWSTR pszTemp;
353 va_list args;
354 int ret;
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]));
364 else
365 pszTitle = lpCaption;
367 if (IS_INTRESOURCE(lpText))
368 LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
369 else
370 pszText = lpText;
372 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
373 pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
375 va_end(args);
377 ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
378 LocalFree((HLOCAL)pszTemp);
379 return ret;
382 /*************************************************************************
383 * ShellMessageBoxA [SHELL32.183]
385 * Format and output an error message.
387 * PARAMS
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
394 * RETURNS
395 * A return value from MessageBoxA().
397 * NOTES
398 * Exported by ordinal
400 int WINAPIV ShellMessageBoxA(
401 HINSTANCE hInstance,
402 HWND hWnd,
403 LPCSTR lpText,
404 LPCSTR lpCaption,
405 UINT uType,
406 ...)
408 char szText[100],szTitle[100];
409 LPCSTR pszText = szText, pszTitle = szTitle;
410 LPSTR pszTemp;
411 va_list args;
412 int ret;
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));
422 else
423 pszTitle = lpCaption;
425 if (IS_INTRESOURCE(lpText))
426 LoadStringA(hInstance, LOWORD(lpText), szText, sizeof(szText));
427 else
428 pszText = lpText;
430 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
431 pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
433 va_end(args);
435 ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
436 LocalFree((HLOCAL)pszTemp);
437 return ret;
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
445 * for details
447 * NOTES
448 * exported by ordinal
450 * SEE ALSO
451 * RegisterDragDrop, SHLoadOLE
453 HRESULT WINAPI SHRegisterDragDrop(
454 HWND hWnd,
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
466 * for details
468 * NOTES
469 * exported by ordinal
471 * SEE ALSO
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
485 * for details
487 * NOTES
488 * exported by ordinal
490 * SEE ALSO
491 * DoDragDrop, SHLoadOLE
493 HRESULT WINAPI SHDoDragDrop(
494 HWND hWnd,
495 LPDATAOBJECT lpDataObject,
496 LPDROPSOURCE lpDropSource,
497 DWORD dwOKEffect,
498 LPDWORD pdwEffect)
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(
510 HWND hwndParent,
511 DWORD dwReserved,
512 LPCRECT lpRect,
513 WORD cKids,
514 CONST HWND * lpKids)
516 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
517 hwndParent, dwReserved, lpRect, cKids, lpKids);
518 return 0;
521 /*************************************************************************
522 * SignalFileOpen [SHELL32.103]
524 * NOTES
525 * exported by ordinal
527 DWORD WINAPI
528 SignalFileOpen (DWORD dwParam1)
530 FIXME("(0x%08x):stub.\n", dwParam1);
532 return 0;
535 /*************************************************************************
536 * SHADD_get_policy - helper function for SHAddToRecentDocs
538 * PARAMETERS
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
543 * length filled
545 * RETURNS
546 * result of the SHQueryValueEx call
548 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
550 HKEY Policy_basekey;
551 INT ret;
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",
563 policy);
564 *len = 0;
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);
573 return ret;
577 /*************************************************************************
578 * SHADD_compare_mru - helper function for SHAddToRecentDocs
580 * PARAMETERS
581 * data1 [IN] data being looked for
582 * data2 [IN] data in MRU
583 * cbdata [IN] length from FindMRUData call (not used)
585 * RETURNS
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
596 * PARAMETERS
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
603 * RETURNS
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)
609 LPSTR ptr;
610 INT wlen;
612 /*FIXME: Document:
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"
624 ptr = buffer;
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 */
632 memset(ptr, 0, 10);
633 ptr += 10;
634 lstrcpyA(ptr, new_lnk_name);
635 ptr += (lstrlenA(new_lnk_name) + 1);
636 memset(ptr, 0, 3);
637 ptr += 3;
638 *len = ptr - buffer;
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.
650 * PARAMETERS
651 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
652 * pv [IN] string or pidl, NULL clears the list
654 * NOTES
655 * exported by name
657 * FIXME
658 * convert to unicode
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?
671 UINT olderrormode;
672 HKEY HCUbasekey;
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];
677 IMalloc *ppM;
678 LPITEMIDLIST pidl;
679 HWND hwnd = 0; /* FIXME: get real window handle */
680 INT ret;
681 DWORD data[64], datalen, type;
683 TRACE("%04x %p\n", uFlags, pv);
685 /*FIXME: Document:
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.
697 datalen = 64;
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);
701 return;
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",
707 type, datalen);
708 return;
711 TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
712 /* now test the actual policy value */
713 if ( data[0] != 0)
714 return;
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");
727 return;
730 /* Get path to user's "Recent" directory
732 if(SUCCEEDED(SHGetMalloc(&ppM))) {
733 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
734 &pidl))) {
735 SHGetPathFromIDListA(pidl, link_dir);
736 IMalloc_Free(ppM, pidl);
738 else {
739 /* serious issues */
740 link_dir[0] = 0;
741 ERR("serious issues 1\n");
743 IMalloc_Release(ppM);
745 else {
746 /* serious issues */
747 link_dir[0] = 0;
748 ERR("serious issues 2\n");
750 TRACE("Users Recent dir %s\n", link_dir);
752 /* If no input, then go clear the lists */
753 if (!pv) {
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);
767 /* clear MRU list
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);
777 return;
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
784 * (CSIDL_RECENT).
785 * 3. Add shortcut to Start menu's Documents submenu.
788 /* Get the pure document name from the input
790 switch (uFlags)
792 case SHARD_PIDL:
793 SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name);
794 break;
796 case SHARD_PATHA:
797 lstrcpynA(doc_name, (LPCSTR)pv, MAX_PATH);
798 break;
800 case SHARD_PATHW:
801 WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pv, -1, doc_name, MAX_PATH, NULL, NULL);
802 break;
804 default:
805 FIXME("Unsupported flags: %u\n", uFlags);
806 return;
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 *** */
816 { /* on input needs:
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
820 * creates:
821 * new_lnk_name- pure file-spec, no path for new .lnk file
822 * new_lnk_filepath
823 * - path and file name of new .lnk file
825 CREATEMRULISTA mymru;
826 HANDLE mruhandle;
827 INT len, pos, bufused, err;
828 INT i;
829 DWORD attr;
830 CHAR buffer[2048];
831 CHAR *ptr;
832 CHAR old_lnk_name[MAX_PATH];
833 short int slen;
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 = &SHADD_compare_mru;
841 mruhandle = CreateMRUListA(&mymru);
842 if (!mruhandle) {
843 /* MRU failed */
844 ERR("MRU processing failed, handle zero\n");
845 RegCloseKey(HCUbasekey);
846 return;
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) {
856 ptr = buffer;
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);
874 else {
875 TRACE("old .lnk file %s did not exist\n",
876 old_lnk_name);
879 else {
880 ERR("Delete for %s failed, attr=%08x\n",
881 old_lnk_name, attr);
884 else {
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);
896 i = 1;
897 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
898 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
899 i++;
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,
910 buffer, &len);
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 *** */
917 { /* on input needs:
918 * doc_name - pure file-spec, no path
919 * new_lnk_filepath
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;
926 HRESULT hres;
927 CHAR desc[MAX_PATH];
928 WCHAR widelink[MAX_PATH];
930 CoInitialize(0);
932 hres = CoCreateInstance( &CLSID_ShellLink,
933 NULL,
934 CLSCTX_INPROC_SERVER,
935 &IID_IShellLinkA,
936 (LPVOID )&psl);
937 if(SUCCEEDED(hres)) {
939 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
940 (LPVOID *)&pPf);
941 if(FAILED(hres)) {
942 /* bombed */
943 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
944 goto fail;
947 /* Set the document path or pidl */
948 if (uFlags == SHARD_PIDL) {
949 hres = IShellLinkA_SetIDList(psl, (LPCITEMIDLIST) pv);
950 } else {
951 hres = IShellLinkA_SetPath(psl, (LPCSTR) pv);
953 if(FAILED(hres)) {
954 /* bombed */
955 ERR("failed Set{IDList|Path} %08x\n", hres);
956 goto fail;
959 lstrcpyA(desc, "Shortcut to ");
960 lstrcatA(desc, doc_name);
961 hres = IShellLinkA_SetDescription(psl, desc);
962 if(FAILED(hres)) {
963 /* bombed */
964 ERR("failed SetDescription %08x\n", hres);
965 goto fail;
968 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
969 widelink, MAX_PATH);
970 /* create the short cut */
971 hres = IPersistFile_Save(pPf, widelink, TRUE);
972 if(FAILED(hres)) {
973 /* bombed */
974 ERR("failed IPersistFile::Save %08x\n", hres);
975 IPersistFile_Release(pPf);
976 IShellLinkA_Release(psl);
977 goto fail;
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);
985 else {
986 ERR("CoCreateInstance failed, hres=%08x\n", hres);
990 fail:
991 CoUninitialize();
993 /* all done */
994 RegCloseKey(HCUbasekey);
995 return;
998 /*************************************************************************
999 * SHCreateShellFolderViewEx [SHELL32.174]
1001 * Create a new instance of the default Shell folder view object.
1003 * RETURNS
1004 * Success: S_OK
1005 * Failure: error value
1007 * NOTES
1008 * see IShellFolder::CreateViewObject
1010 HRESULT WINAPI SHCreateShellFolderViewEx(
1011 LPCSFV psvcbi, /* [in] shelltemplate struct */
1012 IShellView **ppv) /* [out] IShellView pointer */
1014 IShellView * psf;
1015 HRESULT hRes;
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);
1023 if (!psf)
1024 return E_OUTOFMEMORY;
1026 IShellView_AddRef(psf);
1027 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1028 IShellView_Release(psf);
1030 return hRes;
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);
1038 return 0;
1040 /*************************************************************************
1041 * SHRunControlPanel [SHELL32.161]
1044 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
1045 { FIXME("0x%08x 0x%08x stub\n",x,z);
1046 return 0;
1049 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1050 /*************************************************************************
1051 * SHSetInstanceExplorer [SHELL32.176]
1053 * NOTES
1054 * Sets the interface
1056 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1057 { TRACE("%p\n", lpUnknown);
1058 SHELL32_IExplorerInterface = lpUnknown;
1060 /*************************************************************************
1061 * SHGetInstanceExplorer [SHELL32.@]
1063 * NOTES
1064 * gets the interface pointer of the explorer and a reference
1066 HRESULT WINAPI SHGetInstanceExplorer (LPUNKNOWN * lpUnknown)
1067 { TRACE("%p\n", lpUnknown);
1069 *lpUnknown = SHELL32_IExplorerInterface;
1071 if (!SHELL32_IExplorerInterface)
1072 return E_FAIL;
1074 IUnknown_AddRef(SHELL32_IExplorerInterface);
1075 return NOERROR;
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
1082 * for details
1084 * NOTES
1085 * exported by ordinal
1087 * SEE ALSO
1088 * CoFreeUnusedLibraries, SHLoadOLE
1090 void WINAPI SHFreeUnusedLibraries (void)
1092 FIXME("stub\n");
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);
1102 return 0;
1104 /*************************************************************************
1105 * DAD_DragEnter [SHELL32.130]
1108 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1110 FIXME("hwnd = %p\n",hwnd);
1111 return FALSE;
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);
1120 return FALSE;
1122 /*************************************************************************
1123 * DAD_DragMove [SHELL32.134]
1126 BOOL WINAPI DAD_DragMove(POINT p)
1128 FIXME("(%d,%d)\n",p.x,p.y);
1129 return FALSE;
1131 /*************************************************************************
1132 * DAD_DragLeave [SHELL32.132]
1135 BOOL WINAPI DAD_DragLeave(VOID)
1137 FIXME("\n");
1138 return FALSE;
1140 /*************************************************************************
1141 * DAD_SetDragImage [SHELL32.136]
1143 * NOTES
1144 * exported by name
1146 BOOL WINAPI DAD_SetDragImage(
1147 HIMAGELIST himlTrack,
1148 LPPOINT lppt)
1150 FIXME("%p %p stub\n",himlTrack, lppt);
1151 return 0;
1153 /*************************************************************************
1154 * DAD_ShowDragImage [SHELL32.137]
1156 * NOTES
1157 * exported by name
1159 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1161 FIXME("0x%08x stub\n",bShow);
1162 return 0;
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)
1182 HKEY hkey = 0;
1183 DWORD type, r;
1185 TRACE("%p %d\n", cs, length);
1187 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1188 return FALSE;
1190 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1191 if( r == ERROR_SUCCESS )
1193 type = REG_BINARY;
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);
1207 cs->nVersion = 2;
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;
1220 return TRUE;
1223 /*************************************************************************
1224 * WriteCabinetState [SHELL32.652] NT 4.0
1227 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1229 DWORD r;
1230 HKEY hkey = 0;
1232 TRACE("%p\n",cs);
1234 if( cs == NULL )
1235 return FALSE;
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");
1256 return 0;
1258 /*************************************************************************
1259 * IsUserAdmin [SHELL32.680] NT 4.0
1262 HRESULT WINAPI IsUserAdmin(void)
1263 { FIXME("stub\n");
1264 return TRUE;
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 );
1316 return 0;
1319 /*************************************************************************
1320 * SHLoadOLE [SHELL32.151]
1322 * To reduce the memory usage of Windows 95 it's 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 * informations 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);
1340 return S_OK;
1342 /*************************************************************************
1343 * DriveType [SHELL32.64]
1346 HRESULT WINAPI DriveType(DWORD u)
1347 { FIXME("0x%04x stub\n",u);
1348 return 0;
1350 /*************************************************************************
1351 * InvalidateDriveType [SHELL32.65]
1354 int WINAPI InvalidateDriveType(int u)
1355 { FIXME("0x%08x stub\n",u);
1356 return 0;
1358 /*************************************************************************
1359 * SHAbortInvokeCommand [SHELL32.198]
1362 HRESULT WINAPI SHAbortInvokeCommand(void)
1363 { FIXME("stub\n");
1364 return 1;
1366 /*************************************************************************
1367 * SHOutOfMemoryMessageBox [SHELL32.126]
1370 int WINAPI SHOutOfMemoryMessageBox(
1371 HWND hwndOwner,
1372 LPCSTR lpCaption,
1373 UINT uType)
1375 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1376 return 0;
1378 /*************************************************************************
1379 * SHFlushClipboard [SHELL32.121]
1382 HRESULT WINAPI SHFlushClipboard(void)
1383 { FIXME("stub\n");
1384 return 1;
1387 /*************************************************************************
1388 * SHWaitForFileToOpen [SHELL32.97]
1391 BOOL WINAPI SHWaitForFileToOpen(
1392 LPCITEMIDLIST pidl,
1393 DWORD dwFlags,
1394 DWORD dwTimeout)
1396 FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1397 return 0;
1400 /************************************************************************
1401 * @ [SHELL32.654]
1403 * NOTES
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]
1418 * NOTES
1419 * builds a DPA
1421 DWORD WINAPI RLBuildListOfPaths (void)
1422 { FIXME("stub\n");
1423 return 0;
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);
1432 return 0;
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.
1442 * PARAMS
1443 * pszString [I] '\0' terminated string with %keyword%.
1444 * [O] '\0' terminated string with %keyword% substituted.
1445 * cchString [I] size of str.
1447 * RETURNS
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)
1453 LPSTR dst;
1454 BOOL res = FALSE;
1455 FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
1456 if (pszString == NULL) /* Really return 0? */
1457 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 */
1463 res = TRUE;
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 /*************************************************************************
1495 * @ [SHELL32.243]
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)
1504 return FALSE;
1507 /*************************************************************************
1508 * @ [SHELL32.714]
1510 DWORD WINAPI SHELL32_714(LPVOID x)
1512 FIXME("(%s)stub\n", debugstr_w(x));
1513 return 0;
1516 /*************************************************************************
1517 * SHAddFromPropSheetExtArray [SHELL32.167]
1519 DWORD WINAPI SHAddFromPropSheetExtArray(DWORD a, DWORD b, DWORD c)
1521 FIXME("(%08x,%08x,%08x)stub\n", a, b, c);
1522 return 0;
1525 /*************************************************************************
1526 * SHCreatePropSheetExtArray [SHELL32.168]
1528 DWORD WINAPI SHCreatePropSheetExtArray(DWORD a, LPCSTR b, DWORD c)
1530 FIXME("(%08x,%s,%08x)stub\n", a, debugstr_a(b), c);
1531 return 0;
1534 /*************************************************************************
1535 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1537 DWORD WINAPI SHReplaceFromPropSheetExtArray(DWORD a, DWORD b, DWORD c, DWORD d)
1539 FIXME("(%08x,%08x,%08x,%08x)stub\n", a, b, c, d);
1540 return 0;
1543 /*************************************************************************
1544 * SHDestroyPropSheetExtArray [SHELL32.169]
1546 DWORD WINAPI SHDestroyPropSheetExtArray(DWORD a)
1548 FIXME("(%08x)stub\n", a);
1549 return 0;
1552 /*************************************************************************
1553 * CIDLData_CreateFromIDArray [SHELL32.83]
1555 * Create IDataObject from PIDLs??
1557 HRESULT WINAPI CIDLData_CreateFromIDArray(
1558 LPCITEMIDLIST pidlFolder,
1559 DWORD cpidlFiles,
1560 LPCITEMIDLIST *lppidlFiles,
1561 LPDATAOBJECT *ppdataObject)
1563 UINT i;
1564 HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */
1566 TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1567 if (TRACE_ON(pidl))
1569 pdump (pidlFolder);
1570 for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1572 *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1573 lppidlFiles, cpidlFiles);
1574 if (*ppdataObject) return S_OK;
1575 return E_OUTOFMEMORY;
1578 /*************************************************************************
1579 * SHCreateStdEnumFmtEtc [SHELL32.74]
1581 * NOTES
1584 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1585 DWORD cFormats,
1586 const FORMATETC *lpFormats,
1587 LPENUMFORMATETC *ppenumFormatetc)
1589 IEnumFORMATETC *pef;
1590 HRESULT hRes;
1591 TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1593 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1594 if (!pef)
1595 return E_OUTOFMEMORY;
1597 IEnumFORMATETC_AddRef(pef);
1598 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1599 IEnumFORMATETC_Release(pef);
1601 return hRes;
1605 /*************************************************************************
1606 * SHELL32_256 (SHELL32.256)
1608 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1610 HRESULT ret = S_OK;
1612 FIXME("stub %p 0x%08x %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1614 if (!lpdw0 || *lpdw0 != 0x10)
1615 ret = E_INVALIDARG;
1616 else
1618 LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1620 if (!lpdata)
1621 ret = E_OUTOFMEMORY;
1622 else
1624 /* Initialize and return unknown lpdata structure */
1628 return ret;
1631 /*************************************************************************
1632 * SHFindFiles (SHELL32.90)
1634 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1636 FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1637 return FALSE;
1640 /*************************************************************************
1641 * SHUpdateImageW (SHELL32.192)
1643 * Notifies the shell that an icon in the system image list has been changed.
1645 * PARAMS
1646 * pszHashItem [I] Path to file that contains the icon.
1647 * iIndex [I] Zero-based index of the icon in the file.
1648 * uFlags [I] Flags determining the icon attributes. See notes.
1649 * iImageIndex [I] Index of the icon in the system image list.
1651 * RETURNS
1652 * Nothing
1654 * NOTES
1655 * uFlags can be one or more of the following flags:
1656 * GIL_NOTFILENAME - pszHashItem is not a file name.
1657 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1659 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
1661 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
1664 /*************************************************************************
1665 * SHUpdateImageA (SHELL32.191)
1667 * See SHUpdateImageW.
1669 VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex)
1671 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex);
1674 INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra)
1676 FIXME("%p - stub\n", pidlExtra);
1678 return -1;
1681 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
1683 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
1685 return TRUE;
1688 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
1689 UINT uFlags)
1691 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo), debugstr_a(pszDir),
1692 pszName, pfMustCopy, uFlags);
1694 return FALSE;
1697 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
1698 UINT uFlags)
1700 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
1701 pszName, pfMustCopy, uFlags);
1703 return FALSE;
1706 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
1708 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
1710 return S_OK;
1713 HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
1715 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1717 return S_OK;
1720 HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
1722 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1724 return S_OK;
1727 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
1729 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
1731 return SHFMT_NOFORMAT;
1734 HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1736 FIXME("%s, %p - stub\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1738 pSHQueryRBInfo->i64Size = 0;
1739 pSHQueryRBInfo->i64NumItems = 0;
1741 return S_OK;
1744 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1746 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1748 pSHQueryRBInfo->i64Size = 0;
1749 pSHQueryRBInfo->i64NumItems = 0;
1751 return S_OK;
1754 /*************************************************************************
1755 * SHSetLocalizedName (SHELL32.@)
1757 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
1759 FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
1761 return S_OK;