push ab3cc77eb114d2bd400734a9dccad24563f936a6
[wine/hacks.git] / dlls / shell32 / shellord.c
blobe3b77cfcf78269c00b72c2bbf40335b289c0792f
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 va_list args;
360 int ret;
362 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 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 va_list args;
418 int ret;
420 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 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 9x it could use the
450 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
451 * for details
453 * NOTES
454 * exported by ordinal
456 * SEE ALSO
457 * RegisterDragDrop, SHLoadOLE
459 HRESULT WINAPI SHRegisterDragDrop(
460 HWND hWnd,
461 LPDROPTARGET pDropTarget)
463 FIXME("(%p,%p):stub.\n", hWnd, pDropTarget);
464 return RegisterDragDrop(hWnd, pDropTarget);
467 /*************************************************************************
468 * SHRevokeDragDrop [SHELL32.87]
470 * Probably equivalent to RevokeDragDrop but under Windows 9x it could use the
471 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
472 * for details
474 * NOTES
475 * exported by ordinal
477 * SEE ALSO
478 * RevokeDragDrop, SHLoadOLE
480 HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
482 FIXME("(%p):stub.\n",hWnd);
483 return RevokeDragDrop(hWnd);
486 /*************************************************************************
487 * SHDoDragDrop [SHELL32.88]
489 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
490 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
491 * for details
493 * NOTES
494 * exported by ordinal
496 * SEE ALSO
497 * DoDragDrop, SHLoadOLE
499 HRESULT WINAPI SHDoDragDrop(
500 HWND hWnd,
501 LPDATAOBJECT lpDataObject,
502 LPDROPSOURCE lpDropSource,
503 DWORD dwOKEffect,
504 LPDWORD pdwEffect)
506 FIXME("(%p %p %p 0x%08x %p):stub.\n",
507 hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
508 return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
511 /*************************************************************************
512 * ArrangeWindows [SHELL32.184]
515 WORD WINAPI ArrangeWindows(
516 HWND hwndParent,
517 DWORD dwReserved,
518 LPCRECT lpRect,
519 WORD cKids,
520 CONST HWND * lpKids)
522 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
523 hwndParent, dwReserved, lpRect, cKids, lpKids);
524 return 0;
527 /*************************************************************************
528 * SignalFileOpen [SHELL32.103]
530 * NOTES
531 * exported by ordinal
533 DWORD WINAPI
534 SignalFileOpen (DWORD dwParam1)
536 FIXME("(0x%08x):stub.\n", dwParam1);
538 return 0;
541 /*************************************************************************
542 * SHADD_get_policy - helper function for SHAddToRecentDocs
544 * PARAMETERS
545 * policy [IN] policy name (null termed string) to find
546 * type [OUT] ptr to DWORD to receive type
547 * buffer [OUT] ptr to area to hold data retrieved
548 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
549 * length filled
551 * RETURNS
552 * result of the SHQueryValueEx call
554 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
556 HKEY Policy_basekey;
557 INT ret;
559 /* Get the key for the policies location in the registry
561 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
562 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
563 0, KEY_READ, &Policy_basekey)) {
565 if (RegOpenKeyExA(HKEY_CURRENT_USER,
566 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
567 0, KEY_READ, &Policy_basekey)) {
568 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
569 policy);
570 *len = 0;
571 return ERROR_FILE_NOT_FOUND;
575 /* Retrieve the data if it exists
577 ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len);
578 RegCloseKey(Policy_basekey);
579 return ret;
583 /*************************************************************************
584 * SHADD_compare_mru - helper function for SHAddToRecentDocs
586 * PARAMETERS
587 * data1 [IN] data being looked for
588 * data2 [IN] data in MRU
589 * cbdata [IN] length from FindMRUData call (not used)
591 * RETURNS
592 * position within MRU list that data was added.
594 static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData)
596 return lstrcmpiA(data1, data2);
599 /*************************************************************************
600 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
602 * PARAMETERS
603 * mruhandle [IN] handle for created MRU list
604 * doc_name [IN] null termed pure doc name
605 * new_lnk_name [IN] null termed path and file name for .lnk file
606 * buffer [IN/OUT] 2048 byte area to construct MRU data
607 * len [OUT] ptr to int to receive space used in buffer
609 * RETURNS
610 * position within MRU list that data was added.
612 static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPCSTR doc_name, LPCSTR new_lnk_name,
613 LPSTR buffer, INT *len)
615 LPSTR ptr;
616 INT wlen;
618 /*FIXME: Document:
619 * RecentDocs MRU data structure seems to be:
620 * +0h document file name w/ terminating 0h
621 * +nh short int w/ size of remaining
622 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
623 * +n+4h 10 bytes zeros - unknown
624 * +n+eh shortcut file name w/ terminating 0h
625 * +n+e+nh 3 zero bytes - unknown
628 /* Create the MRU data structure for "RecentDocs"
630 ptr = buffer;
631 lstrcpyA(ptr, doc_name);
632 ptr += (lstrlenA(buffer) + 1);
633 wlen= lstrlenA(new_lnk_name) + 1 + 12;
634 *((short int*)ptr) = wlen;
635 ptr += 2; /* step past the length */
636 *(ptr++) = 0x30; /* unknown reason */
637 *(ptr++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
638 memset(ptr, 0, 10);
639 ptr += 10;
640 lstrcpyA(ptr, new_lnk_name);
641 ptr += (lstrlenA(new_lnk_name) + 1);
642 memset(ptr, 0, 3);
643 ptr += 3;
644 *len = ptr - buffer;
646 /* Add the new entry into the MRU list
648 return AddMRUData(mruhandle, (LPCVOID)buffer, *len);
651 /*************************************************************************
652 * SHAddToRecentDocs [SHELL32.@]
654 * Modify (add/clear) Shell's list of recently used documents.
656 * PARAMETERS
657 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
658 * pv [IN] string or pidl, NULL clears the list
660 * NOTES
661 * exported by name
663 * FIXME
664 * convert to unicode
666 void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
668 /* If list is a string list lpfnCompare has the following prototype
669 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
670 * for binary lists the prototype is
671 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
672 * where cbData is the no. of bytes to compare.
673 * Need to check what return value means identical - 0?
677 UINT olderrormode;
678 HKEY HCUbasekey;
679 CHAR doc_name[MAX_PATH];
680 CHAR link_dir[MAX_PATH];
681 CHAR new_lnk_filepath[MAX_PATH];
682 CHAR new_lnk_name[MAX_PATH];
683 IMalloc *ppM;
684 LPITEMIDLIST pidl;
685 HWND hwnd = 0; /* FIXME: get real window handle */
686 INT ret;
687 DWORD data[64], datalen, type;
689 TRACE("%04x %p\n", uFlags, pv);
691 /*FIXME: Document:
692 * RecentDocs MRU data structure seems to be:
693 * +0h document file name w/ terminating 0h
694 * +nh short int w/ size of remaining
695 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
696 * +n+4h 10 bytes zeros - unknown
697 * +n+eh shortcut file name w/ terminating 0h
698 * +n+e+nh 3 zero bytes - unknown
701 /* See if we need to do anything.
703 datalen = 64;
704 ret=SHADD_get_policy( "NoRecentDocsHistory", &type, &data, &datalen);
705 if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) {
706 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret);
707 return;
709 if (ret == ERROR_SUCCESS) {
710 if (!( (type == REG_DWORD) ||
711 ((type == REG_BINARY) && (datalen == 4)) )) {
712 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
713 type, datalen);
714 return;
717 TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
718 /* now test the actual policy value */
719 if ( data[0] != 0)
720 return;
723 /* Open key to where the necessary info is
725 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
726 * and the close should be done during the _DETACH. The resulting
727 * key is stored in the DLL global data.
729 if (RegCreateKeyExA(HKEY_CURRENT_USER,
730 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
731 0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
732 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
733 return;
736 /* Get path to user's "Recent" directory
738 if(SUCCEEDED(SHGetMalloc(&ppM))) {
739 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
740 &pidl))) {
741 SHGetPathFromIDListA(pidl, link_dir);
742 IMalloc_Free(ppM, pidl);
744 else {
745 /* serious issues */
746 link_dir[0] = 0;
747 ERR("serious issues 1\n");
749 IMalloc_Release(ppM);
751 else {
752 /* serious issues */
753 link_dir[0] = 0;
754 ERR("serious issues 2\n");
756 TRACE("Users Recent dir %s\n", link_dir);
758 /* If no input, then go clear the lists */
759 if (!pv) {
760 /* clear user's Recent dir
763 /* FIXME: delete all files in "link_dir"
765 * while( more files ) {
766 * lstrcpyA(old_lnk_name, link_dir);
767 * PathAppendA(old_lnk_name, filenam);
768 * DeleteFileA(old_lnk_name);
771 FIXME("should delete all files in %s\\\n", link_dir);
773 /* clear MRU list
775 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
776 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
777 * and naturally it fails w/ rc=2. It should do it against
778 * HKEY_CURRENT_USER which is where it is stored, and where
779 * the MRU routines expect it!!!!
781 RegDeleteKeyA(HCUbasekey, "RecentDocs");
782 RegCloseKey(HCUbasekey);
783 return;
786 /* Have data to add, the jobs to be done:
787 * 1. Add document to MRU list in registry "HKCU\Software\
788 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
789 * 2. Add shortcut to document in the user's Recent directory
790 * (CSIDL_RECENT).
791 * 3. Add shortcut to Start menu's Documents submenu.
794 /* Get the pure document name from the input
796 switch (uFlags)
798 case SHARD_PIDL:
799 SHGetPathFromIDListA((LPCITEMIDLIST) pv, doc_name);
800 break;
802 case SHARD_PATHA:
803 lstrcpynA(doc_name, (LPCSTR)pv, MAX_PATH);
804 break;
806 case SHARD_PATHW:
807 WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)pv, -1, doc_name, MAX_PATH, NULL, NULL);
808 break;
810 default:
811 FIXME("Unsupported flags: %u\n", uFlags);
812 return;
815 TRACE("full document name %s\n", debugstr_a(doc_name));
816 PathStripPathA(doc_name);
817 TRACE("stripped document name %s\n", debugstr_a(doc_name));
820 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
822 { /* on input needs:
823 * doc_name - pure file-spec, no path
824 * link_dir - path to the user's Recent directory
825 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
826 * creates:
827 * new_lnk_name- pure file-spec, no path for new .lnk file
828 * new_lnk_filepath
829 * - path and file name of new .lnk file
831 CREATEMRULISTA mymru;
832 HANDLE mruhandle;
833 INT len, pos, bufused, err;
834 INT i;
835 DWORD attr;
836 CHAR buffer[2048];
837 CHAR *ptr;
838 CHAR old_lnk_name[MAX_PATH];
839 short int slen;
841 mymru.cbSize = sizeof(CREATEMRULISTA);
842 mymru.nMaxItems = 15;
843 mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE;
844 mymru.hKey = HCUbasekey;
845 mymru.lpszSubKey = "RecentDocs";
846 mymru.lpfnCompare = (PROC)SHADD_compare_mru;
847 mruhandle = CreateMRUListA(&mymru);
848 if (!mruhandle) {
849 /* MRU failed */
850 ERR("MRU processing failed, handle zero\n");
851 RegCloseKey(HCUbasekey);
852 return;
854 len = lstrlenA(doc_name);
855 pos = FindMRUData(mruhandle, doc_name, len, 0);
857 /* Now get the MRU entry that will be replaced
858 * and delete the .lnk file for it
860 if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos,
861 buffer, 2048)) != -1) {
862 ptr = buffer;
863 ptr += (lstrlenA(buffer) + 1);
864 slen = *((short int*)ptr);
865 ptr += 2; /* skip the length area */
866 if (bufused >= slen + (ptr-buffer)) {
867 /* buffer size looks good */
868 ptr += 12; /* get to string */
869 len = bufused - (ptr-buffer); /* get length of buf remaining */
870 if ((lstrlenA(ptr) > 0) && (lstrlenA(ptr) <= len-1)) {
871 /* appears to be good string */
872 lstrcpyA(old_lnk_name, link_dir);
873 PathAppendA(old_lnk_name, ptr);
874 if (!DeleteFileA(old_lnk_name)) {
875 if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
876 if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
877 ERR("Delete for %s failed, err=%d, attr=%08x\n",
878 old_lnk_name, err, attr);
880 else {
881 TRACE("old .lnk file %s did not exist\n",
882 old_lnk_name);
885 else {
886 ERR("Delete for %s failed, attr=%08x\n",
887 old_lnk_name, attr);
890 else {
891 TRACE("deleted old .lnk file %s\n", old_lnk_name);
897 /* Create usable .lnk file name for the "Recent" directory
899 wsprintfA(new_lnk_name, "%s.lnk", doc_name);
900 lstrcpyA(new_lnk_filepath, link_dir);
901 PathAppendA(new_lnk_filepath, new_lnk_name);
902 i = 1;
903 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
904 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
905 i++;
906 wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
907 lstrcpyA(new_lnk_filepath, link_dir);
908 PathAppendA(new_lnk_filepath, new_lnk_name);
910 SetErrorMode(olderrormode);
911 TRACE("new shortcut will be %s\n", new_lnk_filepath);
913 /* Now add the new MRU entry and data
915 pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name,
916 buffer, &len);
917 FreeMRUList(mruhandle);
918 TRACE("Updated MRU list, new doc is position %d\n", pos);
921 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
923 { /* on input needs:
924 * doc_name - pure file-spec, no path
925 * new_lnk_filepath
926 * - path and file name of new .lnk file
927 * uFlags[in] - flags on call to SHAddToRecentDocs
928 * pv[in] - document path/pidl on call to SHAddToRecentDocs
930 IShellLinkA *psl = NULL;
931 IPersistFile *pPf = NULL;
932 HRESULT hres;
933 CHAR desc[MAX_PATH];
934 WCHAR widelink[MAX_PATH];
936 CoInitialize(0);
938 hres = CoCreateInstance( &CLSID_ShellLink,
939 NULL,
940 CLSCTX_INPROC_SERVER,
941 &IID_IShellLinkA,
942 (LPVOID )&psl);
943 if(SUCCEEDED(hres)) {
945 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
946 (LPVOID *)&pPf);
947 if(FAILED(hres)) {
948 /* bombed */
949 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
950 goto fail;
953 /* Set the document path or pidl */
954 if (uFlags == SHARD_PIDL) {
955 hres = IShellLinkA_SetIDList(psl, (LPCITEMIDLIST) pv);
956 } else {
957 hres = IShellLinkA_SetPath(psl, (LPCSTR) pv);
959 if(FAILED(hres)) {
960 /* bombed */
961 ERR("failed Set{IDList|Path} %08x\n", hres);
962 goto fail;
965 lstrcpyA(desc, "Shortcut to ");
966 lstrcatA(desc, doc_name);
967 hres = IShellLinkA_SetDescription(psl, desc);
968 if(FAILED(hres)) {
969 /* bombed */
970 ERR("failed SetDescription %08x\n", hres);
971 goto fail;
974 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
975 widelink, MAX_PATH);
976 /* create the short cut */
977 hres = IPersistFile_Save(pPf, widelink, TRUE);
978 if(FAILED(hres)) {
979 /* bombed */
980 ERR("failed IPersistFile::Save %08x\n", hres);
981 IPersistFile_Release(pPf);
982 IShellLinkA_Release(psl);
983 goto fail;
985 hres = IPersistFile_SaveCompleted(pPf, widelink);
986 IPersistFile_Release(pPf);
987 IShellLinkA_Release(psl);
988 TRACE("shortcut %s has been created, result=%08x\n",
989 new_lnk_filepath, hres);
991 else {
992 ERR("CoCreateInstance failed, hres=%08x\n", hres);
996 fail:
997 CoUninitialize();
999 /* all done */
1000 RegCloseKey(HCUbasekey);
1001 return;
1004 /*************************************************************************
1005 * SHCreateShellFolderViewEx [SHELL32.174]
1007 * Create a new instance of the default Shell folder view object.
1009 * RETURNS
1010 * Success: S_OK
1011 * Failure: error value
1013 * NOTES
1014 * see IShellFolder::CreateViewObject
1016 HRESULT WINAPI SHCreateShellFolderViewEx(
1017 LPCSFV psvcbi, /* [in] shelltemplate struct */
1018 IShellView **ppv) /* [out] IShellView pointer */
1020 IShellView * psf;
1021 HRESULT hRes;
1023 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1024 psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
1025 psvcbi->fvm, psvcbi->psvOuter);
1027 psf = IShellView_Constructor(psvcbi->pshf);
1029 if (!psf)
1030 return E_OUTOFMEMORY;
1032 IShellView_AddRef(psf);
1033 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1034 IShellView_Release(psf);
1036 return hRes;
1038 /*************************************************************************
1039 * SHWinHelp [SHELL32.127]
1042 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
1043 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v,w,x,z);
1044 return 0;
1046 /*************************************************************************
1047 * SHRunControlPanel [SHELL32.161]
1050 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
1051 { FIXME("0x%08x 0x%08x stub\n",x,z);
1052 return 0;
1055 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1056 /*************************************************************************
1057 * SHSetInstanceExplorer [SHELL32.176]
1059 * NOTES
1060 * Sets the interface
1062 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1063 { TRACE("%p\n", lpUnknown);
1064 SHELL32_IExplorerInterface = lpUnknown;
1066 /*************************************************************************
1067 * SHGetInstanceExplorer [SHELL32.@]
1069 * NOTES
1070 * gets the interface pointer of the explorer and a reference
1072 HRESULT WINAPI SHGetInstanceExplorer (IUnknown **lpUnknown)
1073 { TRACE("%p\n", lpUnknown);
1075 *lpUnknown = SHELL32_IExplorerInterface;
1077 if (!SHELL32_IExplorerInterface)
1078 return E_FAIL;
1080 IUnknown_AddRef(SHELL32_IExplorerInterface);
1081 return NOERROR;
1083 /*************************************************************************
1084 * SHFreeUnusedLibraries [SHELL32.123]
1086 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1087 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1088 * for details
1090 * NOTES
1091 * exported by ordinal
1093 * SEE ALSO
1094 * CoFreeUnusedLibraries, SHLoadOLE
1096 void WINAPI SHFreeUnusedLibraries (void)
1098 FIXME("stub\n");
1099 CoFreeUnusedLibraries();
1101 /*************************************************************************
1102 * DAD_AutoScroll [SHELL32.129]
1105 BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, LPPOINT pt)
1107 FIXME("hwnd = %p %p %p\n",hwnd,samples,pt);
1108 return 0;
1110 /*************************************************************************
1111 * DAD_DragEnter [SHELL32.130]
1114 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1116 FIXME("hwnd = %p\n",hwnd);
1117 return FALSE;
1119 /*************************************************************************
1120 * DAD_DragEnterEx [SHELL32.131]
1123 BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p)
1125 FIXME("hwnd = %p (%d,%d)\n",hwnd,p.x,p.y);
1126 return FALSE;
1128 /*************************************************************************
1129 * DAD_DragMove [SHELL32.134]
1132 BOOL WINAPI DAD_DragMove(POINT p)
1134 FIXME("(%d,%d)\n",p.x,p.y);
1135 return FALSE;
1137 /*************************************************************************
1138 * DAD_DragLeave [SHELL32.132]
1141 BOOL WINAPI DAD_DragLeave(VOID)
1143 FIXME("\n");
1144 return FALSE;
1146 /*************************************************************************
1147 * DAD_SetDragImage [SHELL32.136]
1149 * NOTES
1150 * exported by name
1152 BOOL WINAPI DAD_SetDragImage(
1153 HIMAGELIST himlTrack,
1154 LPPOINT lppt)
1156 FIXME("%p %p stub\n",himlTrack, lppt);
1157 return 0;
1159 /*************************************************************************
1160 * DAD_ShowDragImage [SHELL32.137]
1162 * NOTES
1163 * exported by name
1165 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1167 FIXME("0x%08x stub\n",bShow);
1168 return 0;
1171 static const WCHAR szwCabLocation[] = {
1172 'S','o','f','t','w','a','r','e','\\',
1173 'M','i','c','r','o','s','o','f','t','\\',
1174 'W','i','n','d','o','w','s','\\',
1175 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1176 'E','x','p','l','o','r','e','r','\\',
1177 'C','a','b','i','n','e','t','S','t','a','t','e',0
1180 static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 };
1182 /*************************************************************************
1183 * ReadCabinetState [SHELL32.651] NT 4.0
1186 BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
1188 HKEY hkey = 0;
1189 DWORD type, r;
1191 TRACE("%p %d\n", cs, length);
1193 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1194 return FALSE;
1196 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1197 if( r == ERROR_SUCCESS )
1199 type = REG_BINARY;
1200 r = RegQueryValueExW( hkey, szwSettings,
1201 NULL, &type, (LPBYTE)cs, (LPDWORD)&length );
1202 RegCloseKey( hkey );
1206 /* if we can't read from the registry, create default values */
1207 if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) ||
1208 (cs->cLength != length) )
1210 ERR("Initializing shell cabinet settings\n");
1211 memset(cs, 0, sizeof(*cs));
1212 cs->cLength = sizeof(*cs);
1213 cs->nVersion = 2;
1214 cs->fFullPathTitle = FALSE;
1215 cs->fSaveLocalView = TRUE;
1216 cs->fNotShell = FALSE;
1217 cs->fSimpleDefault = TRUE;
1218 cs->fDontShowDescBar = FALSE;
1219 cs->fNewWindowMode = FALSE;
1220 cs->fShowCompColor = FALSE;
1221 cs->fDontPrettyNames = FALSE;
1222 cs->fAdminsCreateCommonGroups = TRUE;
1223 cs->fMenuEnumFilter = 96;
1226 return TRUE;
1229 /*************************************************************************
1230 * WriteCabinetState [SHELL32.652] NT 4.0
1233 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1235 DWORD r;
1236 HKEY hkey = 0;
1238 TRACE("%p\n",cs);
1240 if( cs == NULL )
1241 return FALSE;
1243 r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0,
1244 NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
1245 if( r == ERROR_SUCCESS )
1247 r = RegSetValueExW( hkey, szwSettings, 0,
1248 REG_BINARY, (LPBYTE) cs, cs->cLength);
1250 RegCloseKey( hkey );
1253 return (r==ERROR_SUCCESS);
1256 /*************************************************************************
1257 * FileIconInit [SHELL32.660]
1260 BOOL WINAPI FileIconInit(BOOL bFullInit)
1261 { FIXME("(%s)\n", bFullInit ? "true" : "false");
1262 return 0;
1264 /*************************************************************************
1265 * IsUserAdmin [SHELL32.680] NT 4.0
1268 HRESULT WINAPI IsUserAdmin(void)
1269 { FIXME("stub\n");
1270 return TRUE;
1273 /*************************************************************************
1274 * SHAllocShared [SHELL32.520]
1276 * See shlwapi.SHAllocShared
1278 HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
1280 GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
1281 return pSHAllocShared(lpvData, dwSize, dwProcId);
1284 /*************************************************************************
1285 * SHLockShared [SHELL32.521]
1287 * See shlwapi.SHLockShared
1289 LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
1291 GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
1292 return pSHLockShared(hShared, dwProcId);
1295 /*************************************************************************
1296 * SHUnlockShared [SHELL32.522]
1298 * See shlwapi.SHUnlockShared
1300 BOOL WINAPI SHUnlockShared(LPVOID lpView)
1302 GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
1303 return pSHUnlockShared(lpView);
1306 /*************************************************************************
1307 * SHFreeShared [SHELL32.523]
1309 * See shlwapi.SHFreeShared
1311 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
1313 GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
1314 return pSHFreeShared(hShared, dwProcId);
1317 /*************************************************************************
1318 * SetAppStartingCursor [SHELL32.99]
1320 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1321 { FIXME("hwnd=%p 0x%04x stub\n",u,v );
1322 return 0;
1325 /*************************************************************************
1326 * SHLoadOLE [SHELL32.151]
1328 * To reduce the memory usage of Windows 95, its shell32 contained an
1329 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1330 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1331 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1332 * would just call the Co* functions.
1334 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1335 * information from the shell32 "mini-COM" to ole32.dll.
1337 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1338 * detailed description.
1340 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1341 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1342 * hack in SHCoCreateInstance)
1344 HRESULT WINAPI SHLoadOLE(LPARAM lParam)
1345 { FIXME("0x%08lx stub\n",lParam);
1346 return S_OK;
1348 /*************************************************************************
1349 * DriveType [SHELL32.64]
1352 HRESULT WINAPI DriveType(DWORD u)
1353 { FIXME("0x%04x stub\n",u);
1354 return 0;
1356 /*************************************************************************
1357 * InvalidateDriveType [SHELL32.65]
1360 int WINAPI InvalidateDriveType(int u)
1361 { FIXME("0x%08x stub\n",u);
1362 return 0;
1364 /*************************************************************************
1365 * SHAbortInvokeCommand [SHELL32.198]
1368 HRESULT WINAPI SHAbortInvokeCommand(void)
1369 { FIXME("stub\n");
1370 return 1;
1372 /*************************************************************************
1373 * SHOutOfMemoryMessageBox [SHELL32.126]
1376 int WINAPI SHOutOfMemoryMessageBox(
1377 HWND hwndOwner,
1378 LPCSTR lpCaption,
1379 UINT uType)
1381 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1382 return 0;
1384 /*************************************************************************
1385 * SHFlushClipboard [SHELL32.121]
1388 HRESULT WINAPI SHFlushClipboard(void)
1389 { FIXME("stub\n");
1390 return 1;
1393 /*************************************************************************
1394 * SHWaitForFileToOpen [SHELL32.97]
1397 BOOL WINAPI SHWaitForFileToOpen(
1398 LPCITEMIDLIST pidl,
1399 DWORD dwFlags,
1400 DWORD dwTimeout)
1402 FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1403 return 0;
1406 /************************************************************************
1407 * @ [SHELL32.654]
1409 * NOTES
1410 * first parameter seems to be a pointer (same as passed to WriteCabinetState)
1411 * second one could be a size (0x0c). The size is the same as the structure saved to
1412 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1413 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1415 HRESULT WINAPI shell32_654 (CABINETSTATE *cs, int length)
1417 TRACE("%p %d\n",cs,length);
1418 return ReadCabinetState(cs,length);
1421 /************************************************************************
1422 * RLBuildListOfPaths [SHELL32.146]
1424 * NOTES
1425 * builds a DPA
1427 DWORD WINAPI RLBuildListOfPaths (void)
1428 { FIXME("stub\n");
1429 return 0;
1431 /************************************************************************
1432 * SHValidateUNC [SHELL32.173]
1435 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1437 FIXME("0x%08x 0x%08x 0x%08x stub\n",x,y,z);
1438 return 0;
1441 /************************************************************************
1442 * DoEnvironmentSubstA [SHELL32.@]
1444 * Replace %KEYWORD% in the str with the value of variable KEYWORD
1445 * from environment. If it is not found the %KEYWORD% is left
1446 * intact. If the buffer is too small, str is not modified.
1448 * PARAMS
1449 * pszString [I] '\0' terminated string with %keyword%.
1450 * [O] '\0' terminated string with %keyword% substituted.
1451 * cchString [I] size of str.
1453 * RETURNS
1454 * cchString length in the HIWORD;
1455 * TRUE in LOWORD if subst was successful and FALSE in other case
1457 DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
1459 LPSTR dst;
1460 BOOL res = FALSE;
1461 FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
1462 if (pszString == NULL) /* Really return 0? */
1463 return 0;
1464 if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
1466 DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
1467 if (num && num < cchString) /* dest buffer is too small */
1469 res = TRUE;
1470 memcpy(pszString, dst, num);
1472 HeapFree(GetProcessHeap(), 0, dst);
1474 return MAKELONG(res,cchString); /* Always cchString? */
1477 /************************************************************************
1478 * DoEnvironmentSubstW [SHELL32.@]
1480 * See DoEnvironmentSubstA.
1482 DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
1484 FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
1485 return MAKELONG(FALSE,cchString);
1488 /************************************************************************
1489 * DoEnvironmentSubst [SHELL32.53]
1491 * See DoEnvironmentSubstA.
1493 DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y)
1495 if (SHELL_OsIsUnicode())
1496 return DoEnvironmentSubstW(x, y);
1497 return DoEnvironmentSubstA(x, y);
1500 /*************************************************************************
1501 * @ [SHELL32.243]
1503 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1504 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1508 BOOL WINAPI shell32_243(DWORD a, DWORD b)
1510 return FALSE;
1513 /*************************************************************************
1514 * @ [SHELL32.714]
1516 DWORD WINAPI SHELL32_714(LPVOID x)
1518 FIXME("(%s)stub\n", debugstr_w(x));
1519 return 0;
1522 typedef struct _PSXA
1524 UINT uiCount;
1525 UINT uiAllocated;
1526 IShellPropSheetExt *pspsx[1];
1527 } PSXA, *PPSXA;
1529 typedef struct _PSXA_CALL
1531 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith;
1532 LPARAM lParam;
1533 BOOL bCalled;
1534 BOOL bMultiple;
1535 UINT uiCount;
1536 } PSXA_CALL, *PPSXA_CALL;
1538 static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam)
1540 PPSXA_CALL Call = (PPSXA_CALL)lParam;
1542 if (Call != NULL)
1544 if ((Call->bMultiple || !Call->bCalled) &&
1545 Call->lpfnAddReplaceWith(hpage, Call->lParam))
1547 Call->bCalled = TRUE;
1548 Call->uiCount++;
1549 return TRUE;
1553 return FALSE;
1556 /*************************************************************************
1557 * SHAddFromPropSheetExtArray [SHELL32.167]
1559 UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
1561 PSXA_CALL Call;
1562 UINT i;
1563 PPSXA psxa = (PPSXA)hpsxa;
1565 TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam);
1567 if (psxa)
1569 ZeroMemory(&Call, sizeof(Call));
1570 Call.lpfnAddReplaceWith = lpfnAddPage;
1571 Call.lParam = lParam;
1572 Call.bMultiple = TRUE;
1574 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1575 for (i = 0; i != psxa->uiCount; i++)
1577 psxa->pspsx[i]->lpVtbl->AddPages(psxa->pspsx[i], PsxaCall, (LPARAM)&Call);
1580 return Call.uiCount;
1583 return 0;
1586 /*************************************************************************
1587 * SHCreatePropSheetExtArray [SHELL32.168]
1589 HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
1591 return SHCreatePropSheetExtArrayEx(hKey, pszSubKey, max_iface, NULL);
1594 /*************************************************************************
1595 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1597 HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
1599 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};
1600 WCHAR szHandler[64];
1601 DWORD dwHandlerLen;
1602 WCHAR szClsidHandler[39];
1603 DWORD dwClsidSize;
1604 CLSID clsid;
1605 LONG lRet;
1606 DWORD dwIndex;
1607 IShellExtInit *psxi;
1608 IShellPropSheetExt *pspsx;
1609 HKEY hkBase, hkPropSheetHandlers;
1610 PPSXA psxa = NULL;
1612 TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface);
1614 if (max_iface == 0)
1615 return NULL;
1617 /* Open the registry key */
1618 lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase);
1619 if (lRet != ERROR_SUCCESS)
1620 return NULL;
1622 lRet = RegOpenKeyExW(hkBase, szPropSheetSubKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkPropSheetHandlers);
1623 RegCloseKey(hkBase);
1624 if (lRet == ERROR_SUCCESS)
1626 /* Create and initialize the Property Sheet Extensions Array */
1627 psxa = (PPSXA)LocalAlloc(LMEM_FIXED, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1628 if (psxa)
1630 ZeroMemory(psxa, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1631 psxa->uiAllocated = max_iface;
1633 /* Enumerate all subkeys and attempt to load the shell extensions */
1634 dwIndex = 0;
1637 dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]);
1638 lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL);
1639 if (lRet != ERROR_SUCCESS)
1641 if (lRet == ERROR_MORE_DATA)
1642 continue;
1644 if (lRet == ERROR_NO_MORE_ITEMS)
1645 lRet = ERROR_SUCCESS;
1646 break;
1649 dwClsidSize = sizeof(szClsidHandler);
1650 if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
1652 /* Force a NULL-termination and convert the string */
1653 szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
1654 if (SUCCEEDED(SHCLSIDFromStringW(szClsidHandler, &clsid)))
1656 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1657 Only if both interfaces are supported it's a real shell extension.
1658 Then call IShellExtInit's Initialize method. */
1659 if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx)))
1661 if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi)))
1663 if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey)))
1665 /* Add the IShellPropSheetExt instance to the array */
1666 psxa->pspsx[psxa->uiCount++] = pspsx;
1668 else
1670 psxi->lpVtbl->Release(psxi);
1671 pspsx->lpVtbl->Release(pspsx);
1674 else
1675 pspsx->lpVtbl->Release(pspsx);
1680 } while (psxa->uiCount != psxa->uiAllocated);
1682 else
1683 lRet = ERROR_NOT_ENOUGH_MEMORY;
1685 RegCloseKey(hkPropSheetHandlers);
1688 if (lRet != ERROR_SUCCESS && psxa)
1690 SHDestroyPropSheetExtArray((HPSXA)psxa);
1691 psxa = NULL;
1694 return (HPSXA)psxa;
1697 /*************************************************************************
1698 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1700 UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
1702 PSXA_CALL Call;
1703 UINT i;
1704 PPSXA psxa = (PPSXA)hpsxa;
1706 TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam);
1708 if (psxa)
1710 ZeroMemory(&Call, sizeof(Call));
1711 Call.lpfnAddReplaceWith = lpfnReplaceWith;
1712 Call.lParam = lParam;
1714 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1715 Each shell extension is only allowed to call the callback once during the callback. */
1716 for (i = 0; i != psxa->uiCount; i++)
1718 Call.bCalled = FALSE;
1719 psxa->pspsx[i]->lpVtbl->ReplacePage(psxa->pspsx[i], uPageID, PsxaCall, (LPARAM)&Call);
1722 return Call.uiCount;
1725 return 0;
1728 /*************************************************************************
1729 * SHDestroyPropSheetExtArray [SHELL32.169]
1731 void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
1733 UINT i;
1734 PPSXA psxa = (PPSXA)hpsxa;
1736 TRACE("(%p)\n", hpsxa);
1738 if (psxa)
1740 for (i = 0; i != psxa->uiCount; i++)
1742 psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]);
1745 LocalFree((HLOCAL)psxa);
1749 /*************************************************************************
1750 * CIDLData_CreateFromIDArray [SHELL32.83]
1752 * Create IDataObject from PIDLs??
1754 HRESULT WINAPI CIDLData_CreateFromIDArray(
1755 LPCITEMIDLIST pidlFolder,
1756 DWORD cpidlFiles,
1757 LPCITEMIDLIST *lppidlFiles,
1758 LPDATAOBJECT *ppdataObject)
1760 UINT i;
1761 HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */
1763 TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1764 if (TRACE_ON(pidl))
1766 pdump (pidlFolder);
1767 for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1769 *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1770 lppidlFiles, cpidlFiles);
1771 if (*ppdataObject) return S_OK;
1772 return E_OUTOFMEMORY;
1775 /*************************************************************************
1776 * SHCreateStdEnumFmtEtc [SHELL32.74]
1778 * NOTES
1781 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1782 DWORD cFormats,
1783 const FORMATETC *lpFormats,
1784 LPENUMFORMATETC *ppenumFormatetc)
1786 IEnumFORMATETC *pef;
1787 HRESULT hRes;
1788 TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1790 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1791 if (!pef)
1792 return E_OUTOFMEMORY;
1794 IEnumFORMATETC_AddRef(pef);
1795 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1796 IEnumFORMATETC_Release(pef);
1798 return hRes;
1802 /*************************************************************************
1803 * SHELL32_256 (SHELL32.256)
1805 HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
1807 HRESULT ret = S_OK;
1809 FIXME("stub %p 0x%08x %p\n", lpdw0, lpdw0 ? *lpdw0 : 0, lpdw1);
1811 if (!lpdw0 || *lpdw0 != 0x10)
1812 ret = E_INVALIDARG;
1813 else
1815 LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
1817 if (!lpdata)
1818 ret = E_OUTOFMEMORY;
1819 else
1821 /* Initialize and return unknown lpdata structure */
1825 return ret;
1828 /*************************************************************************
1829 * SHFindFiles (SHELL32.90)
1831 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1833 FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1834 return FALSE;
1837 /*************************************************************************
1838 * SHUpdateImageW (SHELL32.192)
1840 * Notifies the shell that an icon in the system image list has been changed.
1842 * PARAMS
1843 * pszHashItem [I] Path to file that contains the icon.
1844 * iIndex [I] Zero-based index of the icon in the file.
1845 * uFlags [I] Flags determining the icon attributes. See notes.
1846 * iImageIndex [I] Index of the icon in the system image list.
1848 * RETURNS
1849 * Nothing
1851 * NOTES
1852 * uFlags can be one or more of the following flags:
1853 * GIL_NOTFILENAME - pszHashItem is not a file name.
1854 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
1856 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
1858 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
1861 /*************************************************************************
1862 * SHUpdateImageA (SHELL32.191)
1864 * See SHUpdateImageW.
1866 VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex)
1868 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex);
1871 INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra)
1873 FIXME("%p - stub\n", pidlExtra);
1875 return -1;
1878 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
1880 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
1882 return TRUE;
1885 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
1886 UINT uFlags)
1888 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_a(pszLinkTo), debugstr_a(pszDir),
1889 pszName, pfMustCopy, uFlags);
1891 return FALSE;
1894 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
1895 UINT uFlags)
1897 FIXME("%s, %s, %p, %p, 0x%08x - stub\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
1898 pszName, pfMustCopy, uFlags);
1900 return FALSE;
1903 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
1905 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
1907 return S_OK;
1910 HRESULT WINAPI SHEmptyRecycleBinA(HWND hwnd, LPCSTR pszRootPath, DWORD dwFlags)
1912 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRootPath), dwFlags);
1914 return S_OK;
1917 HRESULT WINAPI SHEmptyRecycleBinW(HWND hwnd, LPCWSTR pszRootPath, DWORD dwFlags)
1919 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_w(pszRootPath), dwFlags);
1921 return S_OK;
1924 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
1926 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
1928 return SHFMT_NOFORMAT;
1931 HRESULT WINAPI SHQueryRecycleBinA(LPCSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1933 FIXME("%s, %p - stub\n", debugstr_a(pszRootPath), pSHQueryRBInfo);
1935 pSHQueryRBInfo->i64Size = 0;
1936 pSHQueryRBInfo->i64NumItems = 0;
1938 return S_OK;
1941 HRESULT WINAPI SHQueryRecycleBinW(LPCWSTR pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo)
1943 FIXME("%s, %p - stub\n", debugstr_w(pszRootPath), pSHQueryRBInfo);
1945 pSHQueryRBInfo->i64Size = 0;
1946 pSHQueryRBInfo->i64NumItems = 0;
1948 return S_OK;
1951 /*************************************************************************
1952 * SHSetLocalizedName (SHELL32.@)
1954 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
1956 FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
1958 return S_OK;