d3d10core: Implement d3d10_shader_resource_view_SetPrivateDataInterface().
[wine/multimedia.git] / dlls / shell32 / shellord.c
blob914dc5a35f897fd1ec2c08c74149ff6d86a6208d
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"
36 #include "winternl.h"
38 #include "shellapi.h"
39 #include "objbase.h"
40 #include "shlguid.h"
41 #include "wingdi.h"
42 #include "winuser.h"
43 #include "shlobj.h"
44 #include "shell32_main.h"
45 #include "undocshell.h"
46 #include "pidl.h"
47 #include "shlwapi.h"
48 #include "commdlg.h"
49 #include "commoncontrols.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(shell);
52 WINE_DECLARE_DEBUG_CHANNEL(pidl);
54 /* FIXME: !!! move CREATEMRULIST and flags to header file !!! */
55 /* !!! it is in both here and comctl32undoc.c !!! */
56 typedef struct tagCREATEMRULIST
58 DWORD cbSize; /* size of struct */
59 DWORD nMaxItems; /* max no. of items in list */
60 DWORD dwFlags; /* see below */
61 HKEY hKey; /* root reg. key under which list is saved */
62 LPCSTR lpszSubKey; /* reg. subkey */
63 int (CALLBACK *lpfnCompare)(LPCVOID, LPCVOID, DWORD); /* item compare proc */
64 } CREATEMRULISTA, *LPCREATEMRULISTA;
66 /* dwFlags */
67 #define MRUF_STRING_LIST 0 /* list will contain strings */
68 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
69 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
71 extern HANDLE WINAPI CreateMRUListA(LPCREATEMRULISTA lpcml);
72 extern DWORD WINAPI FreeMRUList(HANDLE hMRUList);
73 extern INT WINAPI AddMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData);
74 extern INT WINAPI FindMRUData(HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum);
75 extern INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, DWORD nBufferSize);
78 /* Get a function pointer from a DLL handle */
79 #define GET_FUNC(func, module, name, fail) \
80 do { \
81 if (!func) { \
82 if (!SHELL32_h##module && !(SHELL32_h##module = LoadLibraryA(#module ".dll"))) return fail; \
83 func = (void*)GetProcAddress(SHELL32_h##module, name); \
84 if (!func) return fail; \
85 } \
86 } while (0)
88 /* Function pointers for GET_FUNC macro */
89 static HMODULE SHELL32_hshlwapi=NULL;
90 static HANDLE (WINAPI *pSHAllocShared)(LPCVOID,DWORD,DWORD);
91 static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD);
92 static BOOL (WINAPI *pSHUnlockShared)(LPVOID);
93 static BOOL (WINAPI *pSHFreeShared)(HANDLE,DWORD);
96 /*************************************************************************
97 * ParseFieldA [internal]
99 * copies a field from a ',' delimited string
101 * first field is nField = 1
103 DWORD WINAPI ParseFieldA(
104 LPCSTR src,
105 DWORD nField,
106 LPSTR dst,
107 DWORD len)
109 WARN("(%s,0x%08x,%p,%d) semi-stub.\n",debugstr_a(src),nField,dst,len);
111 if (!src || !src[0] || !dst || !len)
112 return 0;
114 /* skip n fields delimited by ',' */
115 while (nField > 1)
117 if (*src=='\0') return FALSE;
118 if (*(src++)==',') nField--;
121 /* copy part till the next ',' to dst */
122 while ( *src!='\0' && *src!=',' && (len--)>0 ) *(dst++)=*(src++);
124 /* finalize the string */
125 *dst=0x0;
127 return TRUE;
130 /*************************************************************************
131 * ParseFieldW [internal]
133 * copies a field from a ',' delimited string
135 * first field is nField = 1
137 DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len)
139 WARN("(%s,0x%08x,%p,%d) semi-stub.\n", debugstr_w(src), nField, dst, len);
141 if (!src || !src[0] || !dst || !len)
142 return 0;
144 /* skip n fields delimited by ',' */
145 while (nField > 1)
147 if (*src == 0x0) return FALSE;
148 if (*src++ == ',') nField--;
151 /* copy part till the next ',' to dst */
152 while ( *src != 0x0 && *src != ',' && (len--)>0 ) *(dst++) = *(src++);
154 /* finalize the string */
155 *dst = 0x0;
157 return TRUE;
160 /*************************************************************************
161 * ParseField [SHELL32.58]
163 DWORD WINAPI ParseFieldAW(LPCVOID src, DWORD nField, LPVOID dst, DWORD len)
165 if (SHELL_OsIsUnicode())
166 return ParseFieldW(src, nField, dst, len);
167 return ParseFieldA(src, nField, dst, len);
170 /*************************************************************************
171 * GetFileNameFromBrowseA [internal]
173 static BOOL GetFileNameFromBrowseA(
174 HWND hwndOwner,
175 LPSTR lpstrFile,
176 DWORD nMaxFile,
177 LPCSTR lpstrInitialDir,
178 LPCSTR lpstrDefExt,
179 LPCSTR lpstrFilter,
180 LPCSTR lpstrTitle)
182 HMODULE hmodule;
183 BOOL (WINAPI *pGetOpenFileNameA)(LPOPENFILENAMEA);
184 OPENFILENAMEA ofn;
185 BOOL ret;
187 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
188 hwndOwner, lpstrFile, nMaxFile, lpstrInitialDir, lpstrDefExt,
189 lpstrFilter, lpstrTitle);
191 hmodule = LoadLibraryA("comdlg32.dll");
192 if(!hmodule) return FALSE;
193 pGetOpenFileNameA = (void *)GetProcAddress(hmodule, "GetOpenFileNameA");
194 if(!pGetOpenFileNameA)
196 FreeLibrary(hmodule);
197 return FALSE;
200 memset(&ofn, 0, sizeof(ofn));
202 ofn.lStructSize = sizeof(ofn);
203 ofn.hwndOwner = hwndOwner;
204 ofn.lpstrFilter = lpstrFilter;
205 ofn.lpstrFile = lpstrFile;
206 ofn.nMaxFile = nMaxFile;
207 ofn.lpstrInitialDir = lpstrInitialDir;
208 ofn.lpstrTitle = lpstrTitle;
209 ofn.lpstrDefExt = lpstrDefExt;
210 ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
211 ret = pGetOpenFileNameA(&ofn);
213 FreeLibrary(hmodule);
214 return ret;
217 /*************************************************************************
218 * GetFileNameFromBrowseW [internal]
220 static BOOL GetFileNameFromBrowseW(
221 HWND hwndOwner,
222 LPWSTR lpstrFile,
223 DWORD nMaxFile,
224 LPCWSTR lpstrInitialDir,
225 LPCWSTR lpstrDefExt,
226 LPCWSTR lpstrFilter,
227 LPCWSTR lpstrTitle)
229 HMODULE hmodule;
230 BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW);
231 OPENFILENAMEW ofn;
232 BOOL ret;
234 TRACE("%p, %s, %d, %s, %s, %s, %s)\n",
235 hwndOwner, debugstr_w(lpstrFile), nMaxFile, debugstr_w(lpstrInitialDir), debugstr_w(lpstrDefExt),
236 debugstr_w(lpstrFilter), debugstr_w(lpstrTitle));
238 hmodule = LoadLibraryA("comdlg32.dll");
239 if(!hmodule) return FALSE;
240 pGetOpenFileNameW = (void *)GetProcAddress(hmodule, "GetOpenFileNameW");
241 if(!pGetOpenFileNameW)
243 FreeLibrary(hmodule);
244 return FALSE;
247 memset(&ofn, 0, sizeof(ofn));
249 ofn.lStructSize = sizeof(ofn);
250 ofn.hwndOwner = hwndOwner;
251 ofn.lpstrFilter = lpstrFilter;
252 ofn.lpstrFile = lpstrFile;
253 ofn.nMaxFile = nMaxFile;
254 ofn.lpstrInitialDir = lpstrInitialDir;
255 ofn.lpstrTitle = lpstrTitle;
256 ofn.lpstrDefExt = lpstrDefExt;
257 ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
258 ret = pGetOpenFileNameW(&ofn);
260 FreeLibrary(hmodule);
261 return ret;
264 /*************************************************************************
265 * GetFileNameFromBrowse [SHELL32.63]
268 BOOL WINAPI GetFileNameFromBrowseAW(
269 HWND hwndOwner,
270 LPVOID lpstrFile,
271 DWORD nMaxFile,
272 LPCVOID lpstrInitialDir,
273 LPCVOID lpstrDefExt,
274 LPCVOID lpstrFilter,
275 LPCVOID lpstrTitle)
277 if (SHELL_OsIsUnicode())
278 return GetFileNameFromBrowseW(hwndOwner, lpstrFile, nMaxFile, lpstrInitialDir, lpstrDefExt, lpstrFilter, lpstrTitle);
280 return GetFileNameFromBrowseA(hwndOwner, lpstrFile, nMaxFile, lpstrInitialDir, lpstrDefExt, lpstrFilter, lpstrTitle);
283 /*************************************************************************
284 * SHGetSetSettings [SHELL32.68]
286 VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
288 if(bSet)
290 FIXME("%p 0x%08x TRUE\n", lpss, dwMask);
292 else
294 SHGetSettings((LPSHELLFLAGSTATE)lpss,dwMask);
298 /*************************************************************************
299 * SHGetSettings [SHELL32.@]
301 * NOTES
302 * the registry path are for win98 (tested)
303 * and possibly are the same in nt40
306 VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask)
308 HKEY hKey;
309 DWORD dwData;
310 DWORD dwDataSize = sizeof (DWORD);
312 TRACE("(%p 0x%08x)\n",lpsfs,dwMask);
314 if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
315 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0))
316 return;
318 if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize))
319 lpsfs->fShowExtensions = ((dwData == 0) ? 0 : 1);
321 if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize))
322 lpsfs->fShowInfoTip = ((dwData == 0) ? 0 : 1);
324 if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize))
325 lpsfs->fDontPrettyPath = ((dwData == 0) ? 0 : 1);
327 if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize))
328 lpsfs->fHideIcons = ((dwData == 0) ? 0 : 1);
330 if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize))
331 lpsfs->fMapNetDrvBtn = ((dwData == 0) ? 0 : 1);
333 if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize))
334 lpsfs->fShowAttribCol = ((dwData == 0) ? 0 : 1);
336 if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize))
337 { if (dwData == 0)
338 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
339 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
341 else if (dwData == 1)
342 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 1;
343 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
345 else if (dwData == 2)
346 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
347 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 1;
350 RegCloseKey (hKey);
352 TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
355 /*************************************************************************
356 * SHShellFolderView_Message [SHELL32.73]
358 * Send a message to an explorer cabinet window.
360 * PARAMS
361 * hwndCabinet [I] The window containing the shellview to communicate with
362 * dwMessage [I] The SFVM message to send
363 * dwParam [I] Message parameter
365 * RETURNS
366 * fixme.
368 * NOTES
369 * Message SFVM_REARRANGE = 1
371 * This message gets sent when a column gets clicked to instruct the
372 * shell view to re-sort the item list. dwParam identifies the column
373 * that was clicked.
375 LRESULT WINAPI SHShellFolderView_Message(
376 HWND hwndCabinet,
377 UINT uMessage,
378 LPARAM lParam)
380 FIXME("%p %08x %08lx stub\n",hwndCabinet, uMessage, lParam);
381 return 0;
384 /*************************************************************************
385 * RegisterShellHook [SHELL32.181]
387 * Register a shell hook.
389 * PARAMS
390 * hwnd [I] Window handle
391 * dwType [I] Type of hook.
393 * NOTES
394 * Exported by ordinal
396 BOOL WINAPI RegisterShellHook(
397 HWND hWnd,
398 DWORD dwType)
400 FIXME("(%p,0x%08x):stub.\n",hWnd, dwType);
401 return TRUE;
404 /*************************************************************************
405 * ShellMessageBoxW [SHELL32.182]
407 * See ShellMessageBoxA.
409 * NOTE:
410 * shlwapi.ShellMessageBoxWrapW is a duplicate of shell32.ShellMessageBoxW
411 * because we can't forward to it in the .spec file since it's exported by
412 * ordinal. If you change the implementation here please update the code in
413 * shlwapi as well.
415 int WINAPIV ShellMessageBoxW(
416 HINSTANCE hInstance,
417 HWND hWnd,
418 LPCWSTR lpText,
419 LPCWSTR lpCaption,
420 UINT uType,
421 ...)
423 WCHAR szText[100],szTitle[100];
424 LPCWSTR pszText = szText, pszTitle = szTitle;
425 LPWSTR pszTemp;
426 __ms_va_list args;
427 int ret;
429 __ms_va_start(args, uType);
430 /* wvsprintfA(buf,fmt, args); */
432 TRACE("(%p,%p,%p,%p,%08x)\n",
433 hInstance,hWnd,lpText,lpCaption,uType);
435 if (IS_INTRESOURCE(lpCaption))
436 LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
437 else
438 pszTitle = lpCaption;
440 if (IS_INTRESOURCE(lpText))
441 LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
442 else
443 pszText = lpText;
445 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
446 pszText, 0, 0, (LPWSTR)&pszTemp, 0, &args);
448 __ms_va_end(args);
450 ret = MessageBoxW(hWnd,pszTemp,pszTitle,uType);
451 LocalFree(pszTemp);
452 return ret;
455 /*************************************************************************
456 * ShellMessageBoxA [SHELL32.183]
458 * Format and output an error message.
460 * PARAMS
461 * hInstance [I] Instance handle of message creator
462 * hWnd [I] Window handle of message creator
463 * lpText [I] Resource Id of title or LPSTR
464 * lpCaption [I] Resource Id of title or LPSTR
465 * uType [I] Type of error message
467 * RETURNS
468 * A return value from MessageBoxA().
470 * NOTES
471 * Exported by ordinal
473 int WINAPIV ShellMessageBoxA(
474 HINSTANCE hInstance,
475 HWND hWnd,
476 LPCSTR lpText,
477 LPCSTR lpCaption,
478 UINT uType,
479 ...)
481 char szText[100],szTitle[100];
482 LPCSTR pszText = szText, pszTitle = szTitle;
483 LPSTR pszTemp;
484 __ms_va_list args;
485 int ret;
487 __ms_va_start(args, uType);
488 /* wvsprintfA(buf,fmt, args); */
490 TRACE("(%p,%p,%p,%p,%08x)\n",
491 hInstance,hWnd,lpText,lpCaption,uType);
493 if (IS_INTRESOURCE(lpCaption))
494 LoadStringA(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle));
495 else
496 pszTitle = lpCaption;
498 if (IS_INTRESOURCE(lpText))
499 LoadStringA(hInstance, LOWORD(lpText), szText, sizeof(szText));
500 else
501 pszText = lpText;
503 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
504 pszText, 0, 0, (LPSTR)&pszTemp, 0, &args);
506 __ms_va_end(args);
508 ret = MessageBoxA(hWnd,pszTemp,pszTitle,uType);
509 LocalFree(pszTemp);
510 return ret;
513 /*************************************************************************
514 * SHRegisterDragDrop [SHELL32.86]
516 * Probably equivalent to RegisterDragDrop but under Windows 95 it could use the
517 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
518 * for details. Under Windows 98 this function initializes the true OLE when called
519 * the first time, on XP always returns E_OUTOFMEMORY and it got removed from Vista.
521 * We follow Windows 98 behaviour.
523 * NOTES
524 * exported by ordinal
526 * SEE ALSO
527 * RegisterDragDrop, SHLoadOLE
529 HRESULT WINAPI SHRegisterDragDrop(
530 HWND hWnd,
531 LPDROPTARGET pDropTarget)
533 static BOOL ole_initialized = FALSE;
534 HRESULT hr;
536 TRACE("(%p,%p)\n", hWnd, pDropTarget);
538 if (!ole_initialized)
540 hr = OleInitialize(NULL);
541 if (FAILED(hr))
542 return hr;
543 ole_initialized = TRUE;
545 return RegisterDragDrop(hWnd, pDropTarget);
548 /*************************************************************************
549 * SHRevokeDragDrop [SHELL32.87]
551 * Probably equivalent to RevokeDragDrop but under Windows 95 it could use the
552 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
553 * for details. Function removed from Windows Vista.
555 * We call ole32 RevokeDragDrop which seems to work even if OleInitialize was
556 * not called.
558 * NOTES
559 * exported by ordinal
561 * SEE ALSO
562 * RevokeDragDrop, SHLoadOLE
564 HRESULT WINAPI SHRevokeDragDrop(HWND hWnd)
566 TRACE("(%p)\n", hWnd);
567 return RevokeDragDrop(hWnd);
570 /*************************************************************************
571 * SHDoDragDrop [SHELL32.88]
573 * Probably equivalent to DoDragDrop but under Windows 9x it could use the
574 * shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
575 * for details
577 * NOTES
578 * exported by ordinal
580 * SEE ALSO
581 * DoDragDrop, SHLoadOLE
583 HRESULT WINAPI SHDoDragDrop(
584 HWND hWnd,
585 LPDATAOBJECT lpDataObject,
586 LPDROPSOURCE lpDropSource,
587 DWORD dwOKEffect,
588 LPDWORD pdwEffect)
590 FIXME("(%p %p %p 0x%08x %p):stub.\n",
591 hWnd, lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
592 return DoDragDrop(lpDataObject, lpDropSource, dwOKEffect, pdwEffect);
595 /*************************************************************************
596 * ArrangeWindows [SHELL32.184]
599 WORD WINAPI ArrangeWindows(HWND hwndParent, DWORD dwReserved, const RECT *lpRect,
600 WORD cKids, const HWND *lpKids)
602 FIXME("(%p 0x%08x %p 0x%04x %p):stub.\n",
603 hwndParent, dwReserved, lpRect, cKids, lpKids);
604 return 0;
607 /*************************************************************************
608 * SignalFileOpen [SHELL32.103]
610 * NOTES
611 * exported by ordinal
613 BOOL WINAPI
614 SignalFileOpen (PCIDLIST_ABSOLUTE pidl)
616 FIXME("(%p):stub.\n", pidl);
618 return FALSE;
621 /*************************************************************************
622 * SHADD_get_policy - helper function for SHAddToRecentDocs
624 * PARAMETERS
625 * policy [IN] policy name (null termed string) to find
626 * type [OUT] ptr to DWORD to receive type
627 * buffer [OUT] ptr to area to hold data retrieved
628 * len [IN/OUT] ptr to DWORD holding size of buffer and getting
629 * length filled
631 * RETURNS
632 * result of the SHQueryValueEx call
634 static INT SHADD_get_policy(LPCSTR policy, LPDWORD type, LPVOID buffer, LPDWORD len)
636 HKEY Policy_basekey;
637 INT ret;
639 /* Get the key for the policies location in the registry
641 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
642 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
643 0, KEY_READ, &Policy_basekey)) {
645 if (RegOpenKeyExA(HKEY_CURRENT_USER,
646 "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
647 0, KEY_READ, &Policy_basekey)) {
648 TRACE("No Explorer Policies location exists. Policy wanted=%s\n",
649 policy);
650 *len = 0;
651 return ERROR_FILE_NOT_FOUND;
655 /* Retrieve the data if it exists
657 ret = SHQueryValueExA(Policy_basekey, policy, 0, type, buffer, len);
658 RegCloseKey(Policy_basekey);
659 return ret;
663 /*************************************************************************
664 * SHADD_compare_mru - helper function for SHAddToRecentDocs
666 * PARAMETERS
667 * data1 [IN] data being looked for
668 * data2 [IN] data in MRU
669 * cbdata [IN] length from FindMRUData call (not used)
671 * RETURNS
672 * position within MRU list that data was added.
674 static INT CALLBACK SHADD_compare_mru(LPCVOID data1, LPCVOID data2, DWORD cbData)
676 return lstrcmpiA(data1, data2);
679 /*************************************************************************
680 * SHADD_create_add_mru_data - helper function for SHAddToRecentDocs
682 * PARAMETERS
683 * mruhandle [IN] handle for created MRU list
684 * doc_name [IN] null termed pure doc name
685 * new_lnk_name [IN] null termed path and file name for .lnk file
686 * buffer [IN/OUT] 2048 byte area to construct MRU data
687 * len [OUT] ptr to int to receive space used in buffer
689 * RETURNS
690 * position within MRU list that data was added.
692 static INT SHADD_create_add_mru_data(HANDLE mruhandle, LPCSTR doc_name, LPCSTR new_lnk_name,
693 LPSTR buffer, INT *len)
695 LPSTR ptr;
696 INT wlen;
698 /*FIXME: Document:
699 * RecentDocs MRU data structure seems to be:
700 * +0h document file name w/ terminating 0h
701 * +nh short int w/ size of remaining
702 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
703 * +n+4h 10 bytes zeros - unknown
704 * +n+eh shortcut file name w/ terminating 0h
705 * +n+e+nh 3 zero bytes - unknown
708 /* Create the MRU data structure for "RecentDocs"
710 ptr = buffer;
711 lstrcpyA(ptr, doc_name);
712 ptr += (lstrlenA(buffer) + 1);
713 wlen= lstrlenA(new_lnk_name) + 1 + 12;
714 *((short int*)ptr) = wlen;
715 ptr += 2; /* step past the length */
716 *(ptr++) = 0x30; /* unknown reason */
717 *(ptr++) = 0; /* unknown, but can be 0x00, 0x01, 0x02 */
718 memset(ptr, 0, 10);
719 ptr += 10;
720 lstrcpyA(ptr, new_lnk_name);
721 ptr += (lstrlenA(new_lnk_name) + 1);
722 memset(ptr, 0, 3);
723 ptr += 3;
724 *len = ptr - buffer;
726 /* Add the new entry into the MRU list
728 return AddMRUData(mruhandle, buffer, *len);
731 /*************************************************************************
732 * SHAddToRecentDocs [SHELL32.@]
734 * Modify (add/clear) Shell's list of recently used documents.
736 * PARAMETERS
737 * uFlags [IN] SHARD_PATHA, SHARD_PATHW or SHARD_PIDL
738 * pv [IN] string or pidl, NULL clears the list
740 * NOTES
741 * exported by name
743 * FIXME
744 * convert to unicode
746 void WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
748 /* If list is a string list lpfnCompare has the following prototype
749 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
750 * for binary lists the prototype is
751 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
752 * where cbData is the no. of bytes to compare.
753 * Need to check what return value means identical - 0?
757 UINT olderrormode;
758 HKEY HCUbasekey;
759 CHAR doc_name[MAX_PATH];
760 CHAR link_dir[MAX_PATH];
761 CHAR new_lnk_filepath[MAX_PATH];
762 CHAR new_lnk_name[MAX_PATH];
763 IMalloc *ppM;
764 LPITEMIDLIST pidl;
765 HWND hwnd = 0; /* FIXME: get real window handle */
766 INT ret;
767 DWORD data[64], datalen, type;
769 TRACE("%04x %p\n", uFlags, pv);
771 /*FIXME: Document:
772 * RecentDocs MRU data structure seems to be:
773 * +0h document file name w/ terminating 0h
774 * +nh short int w/ size of remaining
775 * +n+2h 02h 30h, or 01h 30h, or 00h 30h - unknown
776 * +n+4h 10 bytes zeros - unknown
777 * +n+eh shortcut file name w/ terminating 0h
778 * +n+e+nh 3 zero bytes - unknown
781 /* See if we need to do anything.
783 datalen = 64;
784 ret=SHADD_get_policy( "NoRecentDocsHistory", &type, data, &datalen);
785 if ((ret > 0) && (ret != ERROR_FILE_NOT_FOUND)) {
786 ERR("Error %d getting policy \"NoRecentDocsHistory\"\n", ret);
787 return;
789 if (ret == ERROR_SUCCESS) {
790 if (!( (type == REG_DWORD) ||
791 ((type == REG_BINARY) && (datalen == 4)) )) {
792 ERR("Error policy data for \"NoRecentDocsHistory\" not formatted correctly, type=%d, len=%d\n",
793 type, datalen);
794 return;
797 TRACE("policy value for NoRecentDocsHistory = %08x\n", data[0]);
798 /* now test the actual policy value */
799 if ( data[0] != 0)
800 return;
803 /* Open key to where the necessary info is
805 /* FIXME: This should be done during DLL PROCESS_ATTACH (or THREAD_ATTACH)
806 * and the close should be done during the _DETACH. The resulting
807 * key is stored in the DLL global data.
809 if (RegCreateKeyExA(HKEY_CURRENT_USER,
810 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
811 0, 0, 0, KEY_READ, 0, &HCUbasekey, 0)) {
812 ERR("Failed to create 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'\n");
813 return;
816 /* Get path to user's "Recent" directory
818 if(SUCCEEDED(SHGetMalloc(&ppM))) {
819 if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, CSIDL_RECENT,
820 &pidl))) {
821 SHGetPathFromIDListA(pidl, link_dir);
822 IMalloc_Free(ppM, pidl);
824 else {
825 /* serious issues */
826 link_dir[0] = 0;
827 ERR("serious issues 1\n");
829 IMalloc_Release(ppM);
831 else {
832 /* serious issues */
833 link_dir[0] = 0;
834 ERR("serious issues 2\n");
836 TRACE("Users Recent dir %s\n", link_dir);
838 /* If no input, then go clear the lists */
839 if (!pv) {
840 /* clear user's Recent dir
843 /* FIXME: delete all files in "link_dir"
845 * while( more files ) {
846 * lstrcpyA(old_lnk_name, link_dir);
847 * PathAppendA(old_lnk_name, filenam);
848 * DeleteFileA(old_lnk_name);
851 FIXME("should delete all files in %s\\\n", link_dir);
853 /* clear MRU list
855 /* MS Bug ?? v4.72.3612.1700 of shell32 does the delete against
856 * HKEY_LOCAL_MACHINE version of ...CurrentVersion\Explorer
857 * and naturally it fails w/ rc=2. It should do it against
858 * HKEY_CURRENT_USER which is where it is stored, and where
859 * the MRU routines expect it!!!!
861 RegDeleteKeyA(HCUbasekey, "RecentDocs");
862 RegCloseKey(HCUbasekey);
863 return;
866 /* Have data to add, the jobs to be done:
867 * 1. Add document to MRU list in registry "HKCU\Software\
868 * Microsoft\Windows\CurrentVersion\Explorer\RecentDocs".
869 * 2. Add shortcut to document in the user's Recent directory
870 * (CSIDL_RECENT).
871 * 3. Add shortcut to Start menu's Documents submenu.
874 /* Get the pure document name from the input
876 switch (uFlags)
878 case SHARD_PIDL:
879 SHGetPathFromIDListA(pv, doc_name);
880 break;
882 case SHARD_PATHA:
883 lstrcpynA(doc_name, pv, MAX_PATH);
884 break;
886 case SHARD_PATHW:
887 WideCharToMultiByte(CP_ACP, 0, pv, -1, doc_name, MAX_PATH, NULL, NULL);
888 break;
890 default:
891 FIXME("Unsupported flags: %u\n", uFlags);
892 return;
895 TRACE("full document name %s\n", debugstr_a(doc_name));
896 PathStripPathA(doc_name);
897 TRACE("stripped document name %s\n", debugstr_a(doc_name));
900 /* *** JOB 1: Update registry for ...\Explorer\RecentDocs list *** */
902 { /* on input needs:
903 * doc_name - pure file-spec, no path
904 * link_dir - path to the user's Recent directory
905 * HCUbasekey - key of ...Windows\CurrentVersion\Explorer" node
906 * creates:
907 * new_lnk_name- pure file-spec, no path for new .lnk file
908 * new_lnk_filepath
909 * - path and file name of new .lnk file
911 CREATEMRULISTA mymru;
912 HANDLE mruhandle;
913 INT len, pos, bufused, err;
914 INT i;
915 DWORD attr;
916 CHAR buffer[2048];
917 CHAR *ptr;
918 CHAR old_lnk_name[MAX_PATH];
919 short int slen;
921 mymru.cbSize = sizeof(CREATEMRULISTA);
922 mymru.nMaxItems = 15;
923 mymru.dwFlags = MRUF_BINARY_LIST | MRUF_DELAYED_SAVE;
924 mymru.hKey = HCUbasekey;
925 mymru.lpszSubKey = "RecentDocs";
926 mymru.lpfnCompare = SHADD_compare_mru;
927 mruhandle = CreateMRUListA(&mymru);
928 if (!mruhandle) {
929 /* MRU failed */
930 ERR("MRU processing failed, handle zero\n");
931 RegCloseKey(HCUbasekey);
932 return;
934 len = lstrlenA(doc_name);
935 pos = FindMRUData(mruhandle, doc_name, len, 0);
937 /* Now get the MRU entry that will be replaced
938 * and delete the .lnk file for it
940 if ((bufused = EnumMRUListA(mruhandle, (pos == -1) ? 14 : pos,
941 buffer, 2048)) != -1) {
942 ptr = buffer;
943 ptr += (lstrlenA(buffer) + 1);
944 slen = *((short int*)ptr);
945 ptr += 2; /* skip the length area */
946 if (bufused >= slen + (ptr-buffer)) {
947 /* buffer size looks good */
948 ptr += 12; /* get to string */
949 len = bufused - (ptr-buffer); /* get length of buf remaining */
950 if (ptr[0] && (lstrlenA(ptr) <= len-1)) {
951 /* appears to be good string */
952 lstrcpyA(old_lnk_name, link_dir);
953 PathAppendA(old_lnk_name, ptr);
954 if (!DeleteFileA(old_lnk_name)) {
955 if ((attr = GetFileAttributesA(old_lnk_name)) == INVALID_FILE_ATTRIBUTES) {
956 if ((err = GetLastError()) != ERROR_FILE_NOT_FOUND) {
957 ERR("Delete for %s failed, err=%d, attr=%08x\n",
958 old_lnk_name, err, attr);
960 else {
961 TRACE("old .lnk file %s did not exist\n",
962 old_lnk_name);
965 else {
966 ERR("Delete for %s failed, attr=%08x\n",
967 old_lnk_name, attr);
970 else {
971 TRACE("deleted old .lnk file %s\n", old_lnk_name);
977 /* Create usable .lnk file name for the "Recent" directory
979 wsprintfA(new_lnk_name, "%s.lnk", doc_name);
980 lstrcpyA(new_lnk_filepath, link_dir);
981 PathAppendA(new_lnk_filepath, new_lnk_name);
982 i = 1;
983 olderrormode = SetErrorMode(SEM_FAILCRITICALERRORS);
984 while (GetFileAttributesA(new_lnk_filepath) != INVALID_FILE_ATTRIBUTES) {
985 i++;
986 wsprintfA(new_lnk_name, "%s (%u).lnk", doc_name, i);
987 lstrcpyA(new_lnk_filepath, link_dir);
988 PathAppendA(new_lnk_filepath, new_lnk_name);
990 SetErrorMode(olderrormode);
991 TRACE("new shortcut will be %s\n", new_lnk_filepath);
993 /* Now add the new MRU entry and data
995 pos = SHADD_create_add_mru_data(mruhandle, doc_name, new_lnk_name,
996 buffer, &len);
997 FreeMRUList(mruhandle);
998 TRACE("Updated MRU list, new doc is position %d\n", pos);
1001 /* *** JOB 2: Create shortcut in user's "Recent" directory *** */
1003 { /* on input needs:
1004 * doc_name - pure file-spec, no path
1005 * new_lnk_filepath
1006 * - path and file name of new .lnk file
1007 * uFlags[in] - flags on call to SHAddToRecentDocs
1008 * pv[in] - document path/pidl on call to SHAddToRecentDocs
1010 IShellLinkA *psl = NULL;
1011 IPersistFile *pPf = NULL;
1012 HRESULT hres;
1013 CHAR desc[MAX_PATH];
1014 WCHAR widelink[MAX_PATH];
1016 CoInitialize(0);
1018 hres = CoCreateInstance( &CLSID_ShellLink,
1019 NULL,
1020 CLSCTX_INPROC_SERVER,
1021 &IID_IShellLinkA,
1022 (LPVOID )&psl);
1023 if(SUCCEEDED(hres)) {
1025 hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile,
1026 (LPVOID *)&pPf);
1027 if(FAILED(hres)) {
1028 /* bombed */
1029 ERR("failed QueryInterface for IPersistFile %08x\n", hres);
1030 goto fail;
1033 /* Set the document path or pidl */
1034 if (uFlags == SHARD_PIDL) {
1035 hres = IShellLinkA_SetIDList(psl, pv);
1036 } else {
1037 hres = IShellLinkA_SetPath(psl, pv);
1039 if(FAILED(hres)) {
1040 /* bombed */
1041 ERR("failed Set{IDList|Path} %08x\n", hres);
1042 goto fail;
1045 lstrcpyA(desc, "Shortcut to ");
1046 lstrcatA(desc, doc_name);
1047 hres = IShellLinkA_SetDescription(psl, desc);
1048 if(FAILED(hres)) {
1049 /* bombed */
1050 ERR("failed SetDescription %08x\n", hres);
1051 goto fail;
1054 MultiByteToWideChar(CP_ACP, 0, new_lnk_filepath, -1,
1055 widelink, MAX_PATH);
1056 /* create the short cut */
1057 hres = IPersistFile_Save(pPf, widelink, TRUE);
1058 if(FAILED(hres)) {
1059 /* bombed */
1060 ERR("failed IPersistFile::Save %08x\n", hres);
1061 IPersistFile_Release(pPf);
1062 IShellLinkA_Release(psl);
1063 goto fail;
1065 hres = IPersistFile_SaveCompleted(pPf, widelink);
1066 IPersistFile_Release(pPf);
1067 IShellLinkA_Release(psl);
1068 TRACE("shortcut %s has been created, result=%08x\n",
1069 new_lnk_filepath, hres);
1071 else {
1072 ERR("CoCreateInstance failed, hres=%08x\n", hres);
1076 fail:
1077 CoUninitialize();
1079 /* all done */
1080 RegCloseKey(HCUbasekey);
1081 return;
1084 /*************************************************************************
1085 * SHCreateShellFolderViewEx [SHELL32.174]
1087 * Create a new instance of the default Shell folder view object.
1089 * RETURNS
1090 * Success: S_OK
1091 * Failure: error value
1093 * NOTES
1094 * see IShellFolder::CreateViewObject
1096 HRESULT WINAPI SHCreateShellFolderViewEx(
1097 LPCSFV psvcbi, /* [in] shelltemplate struct */
1098 IShellView **ppv) /* [out] IShellView pointer */
1100 IShellView * psf;
1101 HRESULT hRes;
1103 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
1104 psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
1105 psvcbi->fvm, psvcbi->psvOuter);
1107 *ppv = NULL;
1108 psf = IShellView_Constructor(psvcbi->pshf);
1110 if (!psf)
1111 return E_OUTOFMEMORY;
1113 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
1114 IShellView_Release(psf);
1116 return hRes;
1118 /*************************************************************************
1119 * SHWinHelp [SHELL32.127]
1122 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
1123 { FIXME("0x%08x 0x%08x 0x%08x 0x%08x stub\n",v,w,x,z);
1124 return 0;
1126 /*************************************************************************
1127 * SHRunControlPanel [SHELL32.161]
1130 BOOL WINAPI SHRunControlPanel (LPCWSTR commandLine, HWND parent)
1132 FIXME("(%s, %p): stub\n", debugstr_w(commandLine), parent);
1133 return FALSE;
1136 static LPUNKNOWN SHELL32_IExplorerInterface=0;
1137 /*************************************************************************
1138 * SHSetInstanceExplorer [SHELL32.176]
1140 * NOTES
1141 * Sets the interface
1143 VOID WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
1144 { TRACE("%p\n", lpUnknown);
1145 SHELL32_IExplorerInterface = lpUnknown;
1147 /*************************************************************************
1148 * SHGetInstanceExplorer [SHELL32.@]
1150 * NOTES
1151 * gets the interface pointer of the explorer and a reference
1153 HRESULT WINAPI SHGetInstanceExplorer (IUnknown **lpUnknown)
1154 { TRACE("%p\n", lpUnknown);
1156 *lpUnknown = SHELL32_IExplorerInterface;
1158 if (!SHELL32_IExplorerInterface)
1159 return E_FAIL;
1161 IUnknown_AddRef(SHELL32_IExplorerInterface);
1162 return S_OK;
1164 /*************************************************************************
1165 * SHFreeUnusedLibraries [SHELL32.123]
1167 * Probably equivalent to CoFreeUnusedLibraries but under Windows 9x it could use
1168 * the shell32 built-in "mini-COM" without the need to load ole32.dll - see SHLoadOLE
1169 * for details
1171 * NOTES
1172 * exported by ordinal
1174 * SEE ALSO
1175 * CoFreeUnusedLibraries, SHLoadOLE
1177 void WINAPI SHFreeUnusedLibraries (void)
1179 FIXME("stub\n");
1180 CoFreeUnusedLibraries();
1182 /*************************************************************************
1183 * DAD_AutoScroll [SHELL32.129]
1186 BOOL WINAPI DAD_AutoScroll(HWND hwnd, AUTO_SCROLL_DATA *samples, LPPOINT pt)
1188 FIXME("hwnd = %p %p %p\n",hwnd,samples,pt);
1189 return FALSE;
1191 /*************************************************************************
1192 * DAD_DragEnter [SHELL32.130]
1195 BOOL WINAPI DAD_DragEnter(HWND hwnd)
1197 FIXME("hwnd = %p\n",hwnd);
1198 return FALSE;
1200 /*************************************************************************
1201 * DAD_DragEnterEx [SHELL32.131]
1204 BOOL WINAPI DAD_DragEnterEx(HWND hwnd, POINT p)
1206 FIXME("hwnd = %p (%d,%d)\n",hwnd,p.x,p.y);
1207 return FALSE;
1209 /*************************************************************************
1210 * DAD_DragMove [SHELL32.134]
1213 BOOL WINAPI DAD_DragMove(POINT p)
1215 FIXME("(%d,%d)\n",p.x,p.y);
1216 return FALSE;
1218 /*************************************************************************
1219 * DAD_DragLeave [SHELL32.132]
1222 BOOL WINAPI DAD_DragLeave(VOID)
1224 FIXME("\n");
1225 return FALSE;
1227 /*************************************************************************
1228 * DAD_SetDragImage [SHELL32.136]
1230 * NOTES
1231 * exported by name
1233 BOOL WINAPI DAD_SetDragImage(
1234 HIMAGELIST himlTrack,
1235 LPPOINT lppt)
1237 FIXME("%p %p stub\n",himlTrack, lppt);
1238 return FALSE;
1240 /*************************************************************************
1241 * DAD_ShowDragImage [SHELL32.137]
1243 * NOTES
1244 * exported by name
1246 BOOL WINAPI DAD_ShowDragImage(BOOL bShow)
1248 FIXME("0x%08x stub\n",bShow);
1249 return FALSE;
1252 static const WCHAR szwCabLocation[] = {
1253 'S','o','f','t','w','a','r','e','\\',
1254 'M','i','c','r','o','s','o','f','t','\\',
1255 'W','i','n','d','o','w','s','\\',
1256 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1257 'E','x','p','l','o','r','e','r','\\',
1258 'C','a','b','i','n','e','t','S','t','a','t','e',0
1261 static const WCHAR szwSettings[] = { 'S','e','t','t','i','n','g','s',0 };
1263 /*************************************************************************
1264 * ReadCabinetState [SHELL32.651] NT 4.0
1267 BOOL WINAPI ReadCabinetState(CABINETSTATE *cs, int length)
1269 HKEY hkey = 0;
1270 DWORD type, r;
1272 TRACE("%p %d\n", cs, length);
1274 if( (cs == NULL) || (length < (int)sizeof(*cs)) )
1275 return FALSE;
1277 r = RegOpenKeyW( HKEY_CURRENT_USER, szwCabLocation, &hkey );
1278 if( r == ERROR_SUCCESS )
1280 type = REG_BINARY;
1281 r = RegQueryValueExW( hkey, szwSettings,
1282 NULL, &type, (LPBYTE)cs, (LPDWORD)&length );
1283 RegCloseKey( hkey );
1287 /* if we can't read from the registry, create default values */
1288 if ( (r != ERROR_SUCCESS) || (cs->cLength < sizeof(*cs)) ||
1289 (cs->cLength != length) )
1291 ERR("Initializing shell cabinet settings\n");
1292 memset(cs, 0, sizeof(*cs));
1293 cs->cLength = sizeof(*cs);
1294 cs->nVersion = 2;
1295 cs->fFullPathTitle = FALSE;
1296 cs->fSaveLocalView = TRUE;
1297 cs->fNotShell = FALSE;
1298 cs->fSimpleDefault = TRUE;
1299 cs->fDontShowDescBar = FALSE;
1300 cs->fNewWindowMode = FALSE;
1301 cs->fShowCompColor = FALSE;
1302 cs->fDontPrettyNames = FALSE;
1303 cs->fAdminsCreateCommonGroups = TRUE;
1304 cs->fMenuEnumFilter = 96;
1307 return TRUE;
1310 /*************************************************************************
1311 * WriteCabinetState [SHELL32.652] NT 4.0
1314 BOOL WINAPI WriteCabinetState(CABINETSTATE *cs)
1316 DWORD r;
1317 HKEY hkey = 0;
1319 TRACE("%p\n",cs);
1321 if( cs == NULL )
1322 return FALSE;
1324 r = RegCreateKeyExW( HKEY_CURRENT_USER, szwCabLocation, 0,
1325 NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
1326 if( r == ERROR_SUCCESS )
1328 r = RegSetValueExW( hkey, szwSettings, 0,
1329 REG_BINARY, (LPBYTE) cs, cs->cLength);
1331 RegCloseKey( hkey );
1334 return (r==ERROR_SUCCESS);
1337 /*************************************************************************
1338 * FileIconInit [SHELL32.660]
1341 BOOL WINAPI FileIconInit(BOOL bFullInit)
1342 { FIXME("(%s)\n", bFullInit ? "true" : "false");
1343 return FALSE;
1346 /*************************************************************************
1347 * IsUserAnAdmin [SHELL32.680] NT 4.0
1349 * Checks whether the current user is a member of the Administrators group.
1351 * PARAMS
1352 * None
1354 * RETURNS
1355 * Success: TRUE
1356 * Failure: FALSE
1358 BOOL WINAPI IsUserAnAdmin(VOID)
1360 SID_IDENTIFIER_AUTHORITY Authority = {SECURITY_NT_AUTHORITY};
1361 HANDLE hToken;
1362 DWORD dwSize;
1363 PTOKEN_GROUPS lpGroups;
1364 PSID lpSid;
1365 DWORD i;
1366 BOOL bResult = FALSE;
1368 TRACE("\n");
1369 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
1371 return FALSE;
1374 if (!GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize))
1376 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
1378 CloseHandle(hToken);
1379 return FALSE;
1383 lpGroups = HeapAlloc(GetProcessHeap(), 0, dwSize);
1384 if (lpGroups == NULL)
1386 CloseHandle(hToken);
1387 return FALSE;
1390 if (!GetTokenInformation(hToken, TokenGroups, lpGroups, dwSize, &dwSize))
1392 HeapFree(GetProcessHeap(), 0, lpGroups);
1393 CloseHandle(hToken);
1394 return FALSE;
1397 CloseHandle(hToken);
1398 if (!AllocateAndInitializeSid(&Authority, 2, SECURITY_BUILTIN_DOMAIN_RID,
1399 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,
1400 &lpSid))
1402 HeapFree(GetProcessHeap(), 0, lpGroups);
1403 return FALSE;
1406 for (i = 0; i < lpGroups->GroupCount; i++)
1408 if (EqualSid(lpSid, lpGroups->Groups[i].Sid))
1410 bResult = TRUE;
1411 break;
1415 FreeSid(lpSid);
1416 HeapFree(GetProcessHeap(), 0, lpGroups);
1417 return bResult;
1420 /*************************************************************************
1421 * SHAllocShared [SHELL32.520]
1423 * See shlwapi.SHAllocShared
1425 HANDLE WINAPI SHAllocShared(LPVOID lpvData, DWORD dwSize, DWORD dwProcId)
1427 GET_FUNC(pSHAllocShared, shlwapi, (char*)7, NULL);
1428 return pSHAllocShared(lpvData, dwSize, dwProcId);
1431 /*************************************************************************
1432 * SHLockShared [SHELL32.521]
1434 * See shlwapi.SHLockShared
1436 LPVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
1438 GET_FUNC(pSHLockShared, shlwapi, (char*)8, NULL);
1439 return pSHLockShared(hShared, dwProcId);
1442 /*************************************************************************
1443 * SHUnlockShared [SHELL32.522]
1445 * See shlwapi.SHUnlockShared
1447 BOOL WINAPI SHUnlockShared(LPVOID lpView)
1449 GET_FUNC(pSHUnlockShared, shlwapi, (char*)9, FALSE);
1450 return pSHUnlockShared(lpView);
1453 /*************************************************************************
1454 * SHFreeShared [SHELL32.523]
1456 * See shlwapi.SHFreeShared
1458 BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
1460 GET_FUNC(pSHFreeShared, shlwapi, (char*)10, FALSE);
1461 return pSHFreeShared(hShared, dwProcId);
1464 /*************************************************************************
1465 * SetAppStartingCursor [SHELL32.99]
1467 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1468 { FIXME("hwnd=%p 0x%04x stub\n",u,v );
1469 return 0;
1472 /*************************************************************************
1473 * SHLoadOLE [SHELL32.151]
1475 * To reduce the memory usage of Windows 95, its shell32 contained an
1476 * internal implementation of a part of COM (see e.g. SHGetMalloc, SHCoCreateInstance,
1477 * SHRegisterDragDrop etc.) that allowed to use in-process STA objects without
1478 * the need to load OLE32.DLL. If OLE32.DLL was already loaded, the SH* function
1479 * would just call the Co* functions.
1481 * The SHLoadOLE was called when OLE32.DLL was being loaded to transfer all the
1482 * information from the shell32 "mini-COM" to ole32.dll.
1484 * See http://blogs.msdn.com/oldnewthing/archive/2004/07/05/173226.aspx for a
1485 * detailed description.
1487 * Under wine ole32.dll is always loaded as it is imported by shlwapi.dll which is
1488 * imported by shell32 and no "mini-COM" is used (except for the "LoadWithoutCOM"
1489 * hack in SHCoCreateInstance)
1491 HRESULT WINAPI SHLoadOLE(LPARAM lParam)
1492 { FIXME("0x%08lx stub\n",lParam);
1493 return S_OK;
1495 /*************************************************************************
1496 * DriveType [SHELL32.64]
1499 int WINAPI DriveType(int u)
1500 { FIXME("0x%04x stub\n",u);
1501 return 0;
1503 /*************************************************************************
1504 * InvalidateDriveType [SHELL32.65]
1507 int WINAPI InvalidateDriveType(int u)
1508 { FIXME("0x%08x stub\n",u);
1509 return 0;
1511 /*************************************************************************
1512 * SHAbortInvokeCommand [SHELL32.198]
1515 HRESULT WINAPI SHAbortInvokeCommand(void)
1516 { FIXME("stub\n");
1517 return 1;
1519 /*************************************************************************
1520 * SHOutOfMemoryMessageBox [SHELL32.126]
1523 int WINAPI SHOutOfMemoryMessageBox(
1524 HWND hwndOwner,
1525 LPCSTR lpCaption,
1526 UINT uType)
1528 FIXME("%p %s 0x%08x stub\n",hwndOwner, lpCaption, uType);
1529 return 0;
1531 /*************************************************************************
1532 * SHFlushClipboard [SHELL32.121]
1535 HRESULT WINAPI SHFlushClipboard(void)
1536 { FIXME("stub\n");
1537 return 1;
1540 /*************************************************************************
1541 * SHWaitForFileToOpen [SHELL32.97]
1544 BOOL WINAPI SHWaitForFileToOpen(
1545 LPCITEMIDLIST pidl,
1546 DWORD dwFlags,
1547 DWORD dwTimeout)
1549 FIXME("%p 0x%08x 0x%08x stub\n", pidl, dwFlags, dwTimeout);
1550 return FALSE;
1553 /************************************************************************
1554 * @ [SHELL32.654]
1556 * NOTES
1557 * first parameter seems to be a pointer (same as passed to WriteCabinetState)
1558 * second one could be a size (0x0c). The size is the same as the structure saved to
1559 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1560 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1562 HRESULT WINAPI shell32_654 (CABINETSTATE *cs, int length)
1564 TRACE("%p %d\n",cs,length);
1565 return ReadCabinetState(cs,length);
1568 /************************************************************************
1569 * RLBuildListOfPaths [SHELL32.146]
1571 * NOTES
1572 * builds a DPA
1574 DWORD WINAPI RLBuildListOfPaths (void)
1575 { FIXME("stub\n");
1576 return 0;
1578 /************************************************************************
1579 * SHValidateUNC [SHELL32.173]
1582 BOOL WINAPI SHValidateUNC (HWND hwndOwner, PWSTR pszFile, UINT fConnect)
1584 FIXME("(%p, %s, 0x%08x): stub\n", hwndOwner, debugstr_w(pszFile), fConnect);
1585 return FALSE;
1588 /************************************************************************
1589 * DoEnvironmentSubstA [SHELL32.@]
1591 * See DoEnvironmentSubstW.
1593 DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
1595 LPSTR dst;
1596 BOOL res = FALSE;
1597 DWORD len = cchString;
1599 TRACE("(%s, %d)\n", debugstr_a(pszString), cchString);
1601 if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
1603 len = ExpandEnvironmentStringsA(pszString, dst, cchString);
1604 /* len includes the terminating 0 */
1605 if (len && len < cchString)
1607 res = TRUE;
1608 memcpy(pszString, dst, len);
1610 else
1611 len = cchString;
1613 HeapFree(GetProcessHeap(), 0, dst);
1615 return MAKELONG(len, res);
1618 /************************************************************************
1619 * DoEnvironmentSubstW [SHELL32.@]
1621 * Replace all %KEYWORD% in the string with the value of the named
1622 * environment variable. If the buffer is too small, the string is not modified.
1624 * PARAMS
1625 * pszString [I] '\0' terminated string with %keyword%.
1626 * [O] '\0' terminated string with %keyword% substituted.
1627 * cchString [I] size of str.
1629 * RETURNS
1630 * Success: The string in the buffer is updated
1631 * HIWORD: TRUE
1632 * LOWORD: characters used in the buffer, including space for the terminating 0
1633 * Failure: buffer too small. The string is not modified.
1634 * HIWORD: FALSE
1635 * LOWORD: provided size of the buffer in characters
1637 DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
1639 LPWSTR dst;
1640 BOOL res = FALSE;
1641 DWORD len = cchString;
1643 TRACE("(%s, %d)\n", debugstr_w(pszString), cchString);
1645 if ((cchString < MAXLONG) && (dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(WCHAR))))
1647 len = ExpandEnvironmentStringsW(pszString, dst, cchString);
1648 /* len includes the terminating 0 */
1649 if (len && len <= cchString)
1651 res = TRUE;
1652 memcpy(pszString, dst, len * sizeof(WCHAR));
1654 else
1655 len = cchString;
1657 HeapFree(GetProcessHeap(), 0, dst);
1659 return MAKELONG(len, res);
1662 /************************************************************************
1663 * DoEnvironmentSubst [SHELL32.53]
1665 * See DoEnvironmentSubstA.
1667 DWORD WINAPI DoEnvironmentSubstAW(LPVOID x, UINT y)
1669 if (SHELL_OsIsUnicode())
1670 return DoEnvironmentSubstW(x, y);
1671 return DoEnvironmentSubstA(x, y);
1674 /*************************************************************************
1675 * @ [SHELL32.243]
1677 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1678 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1682 BOOL WINAPI shell32_243(DWORD a, DWORD b)
1684 return FALSE;
1687 /*************************************************************************
1688 * GUIDFromStringW [SHELL32.704]
1690 BOOL WINAPI GUIDFromStringW(LPCWSTR str, LPGUID guid)
1692 UNICODE_STRING guid_str;
1694 RtlInitUnicodeString(&guid_str, str);
1695 return !RtlGUIDFromString(&guid_str, guid);
1698 /*************************************************************************
1699 * @ [SHELL32.714]
1701 DWORD WINAPI SHELL32_714(LPVOID x)
1703 FIXME("(%s)stub\n", debugstr_w(x));
1704 return 0;
1707 typedef struct _PSXA
1709 UINT uiCount;
1710 UINT uiAllocated;
1711 IShellPropSheetExt *pspsx[1];
1712 } PSXA, *PPSXA;
1714 typedef struct _PSXA_CALL
1716 LPFNADDPROPSHEETPAGE lpfnAddReplaceWith;
1717 LPARAM lParam;
1718 BOOL bCalled;
1719 BOOL bMultiple;
1720 UINT uiCount;
1721 } PSXA_CALL, *PPSXA_CALL;
1723 static BOOL CALLBACK PsxaCall(HPROPSHEETPAGE hpage, LPARAM lParam)
1725 PPSXA_CALL Call = (PPSXA_CALL)lParam;
1727 if (Call != NULL)
1729 if ((Call->bMultiple || !Call->bCalled) &&
1730 Call->lpfnAddReplaceWith(hpage, Call->lParam))
1732 Call->bCalled = TRUE;
1733 Call->uiCount++;
1734 return TRUE;
1738 return FALSE;
1741 /*************************************************************************
1742 * SHAddFromPropSheetExtArray [SHELL32.167]
1744 UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
1746 PSXA_CALL Call;
1747 UINT i;
1748 PPSXA psxa = (PPSXA)hpsxa;
1750 TRACE("(%p,%p,%08lx)\n", hpsxa, lpfnAddPage, lParam);
1752 if (psxa)
1754 ZeroMemory(&Call, sizeof(Call));
1755 Call.lpfnAddReplaceWith = lpfnAddPage;
1756 Call.lParam = lParam;
1757 Call.bMultiple = TRUE;
1759 /* Call the AddPage method of all registered IShellPropSheetExt interfaces */
1760 for (i = 0; i != psxa->uiCount; i++)
1762 psxa->pspsx[i]->lpVtbl->AddPages(psxa->pspsx[i], PsxaCall, (LPARAM)&Call);
1765 return Call.uiCount;
1768 return 0;
1771 /*************************************************************************
1772 * SHCreatePropSheetExtArray [SHELL32.168]
1774 HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
1776 return SHCreatePropSheetExtArrayEx(hKey, pszSubKey, max_iface, NULL);
1779 /*************************************************************************
1780 * SHCreatePropSheetExtArrayEx [SHELL32.194]
1782 HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, LPDATAOBJECT pDataObj)
1784 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};
1785 WCHAR szHandler[64];
1786 DWORD dwHandlerLen;
1787 WCHAR szClsidHandler[39];
1788 DWORD dwClsidSize;
1789 CLSID clsid;
1790 LONG lRet;
1791 DWORD dwIndex;
1792 IShellExtInit *psxi;
1793 IShellPropSheetExt *pspsx;
1794 HKEY hkBase, hkPropSheetHandlers;
1795 PPSXA psxa = NULL;
1797 TRACE("(%p,%s,%u)\n", hKey, debugstr_w(pszSubKey), max_iface);
1799 if (max_iface == 0)
1800 return NULL;
1802 /* Open the registry key */
1803 lRet = RegOpenKeyW(hKey, pszSubKey, &hkBase);
1804 if (lRet != ERROR_SUCCESS)
1805 return NULL;
1807 lRet = RegOpenKeyExW(hkBase, szPropSheetSubKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkPropSheetHandlers);
1808 RegCloseKey(hkBase);
1809 if (lRet == ERROR_SUCCESS)
1811 /* Create and initialize the Property Sheet Extensions Array */
1812 psxa = LocalAlloc(LMEM_FIXED, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1813 if (psxa)
1815 ZeroMemory(psxa, FIELD_OFFSET(PSXA, pspsx[max_iface]));
1816 psxa->uiAllocated = max_iface;
1818 /* Enumerate all subkeys and attempt to load the shell extensions */
1819 dwIndex = 0;
1822 dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]);
1823 lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL);
1824 if (lRet != ERROR_SUCCESS)
1826 if (lRet == ERROR_MORE_DATA)
1827 continue;
1829 if (lRet == ERROR_NO_MORE_ITEMS)
1830 lRet = ERROR_SUCCESS;
1831 break;
1834 /* The CLSID is stored either in the key itself or in its default value. */
1835 if (FAILED(lRet = SHCLSIDFromStringW(szHandler, &clsid)))
1837 dwClsidSize = sizeof(szClsidHandler);
1838 if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
1840 /* Force a NULL-termination and convert the string */
1841 szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
1842 lRet = SHCLSIDFromStringW(szClsidHandler, &clsid);
1846 if (SUCCEEDED(lRet))
1848 /* Attempt to get an IShellPropSheetExt and an IShellExtInit instance.
1849 Only if both interfaces are supported it's a real shell extension.
1850 Then call IShellExtInit's Initialize method. */
1851 if (SUCCEEDED(CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER/* | CLSCTX_NO_CODE_DOWNLOAD */, &IID_IShellPropSheetExt, (LPVOID *)&pspsx)))
1853 if (SUCCEEDED(pspsx->lpVtbl->QueryInterface(pspsx, &IID_IShellExtInit, (PVOID *)&psxi)))
1855 if (SUCCEEDED(psxi->lpVtbl->Initialize(psxi, NULL, pDataObj, hKey)))
1857 /* Add the IShellPropSheetExt instance to the array */
1858 psxa->pspsx[psxa->uiCount++] = pspsx;
1860 else
1862 psxi->lpVtbl->Release(psxi);
1863 pspsx->lpVtbl->Release(pspsx);
1866 else
1867 pspsx->lpVtbl->Release(pspsx);
1871 } while (psxa->uiCount != psxa->uiAllocated);
1873 else
1874 lRet = ERROR_NOT_ENOUGH_MEMORY;
1876 RegCloseKey(hkPropSheetHandlers);
1879 if (lRet != ERROR_SUCCESS && psxa)
1881 SHDestroyPropSheetExtArray((HPSXA)psxa);
1882 psxa = NULL;
1885 return (HPSXA)psxa;
1888 /*************************************************************************
1889 * SHReplaceFromPropSheetExtArray [SHELL32.170]
1891 UINT WINAPI SHReplaceFromPropSheetExtArray(HPSXA hpsxa, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
1893 PSXA_CALL Call;
1894 UINT i;
1895 PPSXA psxa = (PPSXA)hpsxa;
1897 TRACE("(%p,%u,%p,%08lx)\n", hpsxa, uPageID, lpfnReplaceWith, lParam);
1899 if (psxa)
1901 ZeroMemory(&Call, sizeof(Call));
1902 Call.lpfnAddReplaceWith = lpfnReplaceWith;
1903 Call.lParam = lParam;
1905 /* Call the ReplacePage method of all registered IShellPropSheetExt interfaces.
1906 Each shell extension is only allowed to call the callback once during the callback. */
1907 for (i = 0; i != psxa->uiCount; i++)
1909 Call.bCalled = FALSE;
1910 psxa->pspsx[i]->lpVtbl->ReplacePage(psxa->pspsx[i], uPageID, PsxaCall, (LPARAM)&Call);
1913 return Call.uiCount;
1916 return 0;
1919 /*************************************************************************
1920 * SHDestroyPropSheetExtArray [SHELL32.169]
1922 void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
1924 UINT i;
1925 PPSXA psxa = (PPSXA)hpsxa;
1927 TRACE("(%p)\n", hpsxa);
1929 if (psxa)
1931 for (i = 0; i != psxa->uiCount; i++)
1933 psxa->pspsx[i]->lpVtbl->Release(psxa->pspsx[i]);
1936 LocalFree(psxa);
1940 /*************************************************************************
1941 * CIDLData_CreateFromIDArray [SHELL32.83]
1943 * Create IDataObject from PIDLs??
1945 HRESULT WINAPI CIDLData_CreateFromIDArray(
1946 LPCITEMIDLIST pidlFolder,
1947 DWORD cpidlFiles,
1948 LPCITEMIDLIST *lppidlFiles,
1949 LPDATAOBJECT *ppdataObject)
1951 UINT i;
1952 HWND hwnd = 0; /*FIXME: who should be hwnd of owner? set to desktop */
1954 TRACE("(%p, %d, %p, %p)\n", pidlFolder, cpidlFiles, lppidlFiles, ppdataObject);
1955 if (TRACE_ON(pidl))
1957 pdump (pidlFolder);
1958 for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
1960 *ppdataObject = IDataObject_Constructor( hwnd, pidlFolder,
1961 lppidlFiles, cpidlFiles);
1962 if (*ppdataObject) return S_OK;
1963 return E_OUTOFMEMORY;
1966 /*************************************************************************
1967 * SHCreateStdEnumFmtEtc [SHELL32.74]
1969 * NOTES
1972 HRESULT WINAPI SHCreateStdEnumFmtEtc(
1973 DWORD cFormats,
1974 const FORMATETC *lpFormats,
1975 LPENUMFORMATETC *ppenumFormatetc)
1977 IEnumFORMATETC *pef;
1978 HRESULT hRes;
1979 TRACE("cf=%d fe=%p pef=%p\n", cFormats, lpFormats, ppenumFormatetc);
1981 pef = IEnumFORMATETC_Constructor(cFormats, lpFormats);
1982 if (!pef)
1983 return E_OUTOFMEMORY;
1985 IEnumFORMATETC_AddRef(pef);
1986 hRes = IEnumFORMATETC_QueryInterface(pef, &IID_IEnumFORMATETC, (LPVOID*)ppenumFormatetc);
1987 IEnumFORMATETC_Release(pef);
1989 return hRes;
1992 /*************************************************************************
1993 * SHFindFiles (SHELL32.90)
1995 BOOL WINAPI SHFindFiles( LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidlSaveFile )
1997 FIXME("%p %p\n", pidlFolder, pidlSaveFile );
1998 return FALSE;
2001 /*************************************************************************
2002 * SHUpdateImageW (SHELL32.192)
2004 * Notifies the shell that an icon in the system image list has been changed.
2006 * PARAMS
2007 * pszHashItem [I] Path to file that contains the icon.
2008 * iIndex [I] Zero-based index of the icon in the file.
2009 * uFlags [I] Flags determining the icon attributes. See notes.
2010 * iImageIndex [I] Index of the icon in the system image list.
2012 * RETURNS
2013 * Nothing
2015 * NOTES
2016 * uFlags can be one or more of the following flags:
2017 * GIL_NOTFILENAME - pszHashItem is not a file name.
2018 * GIL_SIMULATEDOC - Create a document icon using the specified icon.
2020 void WINAPI SHUpdateImageW(LPCWSTR pszHashItem, int iIndex, UINT uFlags, int iImageIndex)
2022 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_w(pszHashItem), iIndex, uFlags, iImageIndex);
2025 /*************************************************************************
2026 * SHUpdateImageA (SHELL32.191)
2028 * See SHUpdateImageW.
2030 VOID WINAPI SHUpdateImageA(LPCSTR pszHashItem, INT iIndex, UINT uFlags, INT iImageIndex)
2032 FIXME("%s, %d, 0x%x, %d - stub\n", debugstr_a(pszHashItem), iIndex, uFlags, iImageIndex);
2035 INT WINAPI SHHandleUpdateImage(LPCITEMIDLIST pidlExtra)
2037 FIXME("%p - stub\n", pidlExtra);
2039 return -1;
2042 BOOL WINAPI SHObjectProperties(HWND hwnd, DWORD dwType, LPCWSTR szObject, LPCWSTR szPage)
2044 FIXME("%p, 0x%08x, %s, %s - stub\n", hwnd, dwType, debugstr_w(szObject), debugstr_w(szPage));
2046 return TRUE;
2049 BOOL WINAPI SHGetNewLinkInfoA(LPCSTR pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy,
2050 UINT uFlags)
2052 WCHAR wszLinkTo[MAX_PATH];
2053 WCHAR wszDir[MAX_PATH];
2054 WCHAR wszName[MAX_PATH];
2055 BOOL res;
2057 MultiByteToWideChar(CP_ACP, 0, pszLinkTo, -1, wszLinkTo, MAX_PATH);
2058 MultiByteToWideChar(CP_ACP, 0, pszDir, -1, wszDir, MAX_PATH);
2060 res = SHGetNewLinkInfoW(wszLinkTo, wszDir, wszName, pfMustCopy, uFlags);
2062 if (res)
2063 WideCharToMultiByte(CP_ACP, 0, wszName, -1, pszName, MAX_PATH, NULL, NULL);
2065 return res;
2068 BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy,
2069 UINT uFlags)
2071 const WCHAR *basename;
2072 WCHAR *dst_basename;
2073 int i=2;
2074 static const WCHAR lnkformat[] = {'%','s','.','l','n','k',0};
2075 static const WCHAR lnkformatnum[] = {'%','s',' ','(','%','d',')','.','l','n','k',0};
2077 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(pszLinkTo), debugstr_w(pszDir),
2078 pszName, pfMustCopy, uFlags);
2080 *pfMustCopy = FALSE;
2082 if (uFlags & SHGNLI_PIDL)
2084 FIXME("SHGNLI_PIDL flag unsupported\n");
2085 return FALSE;
2088 if (uFlags)
2089 FIXME("ignoring flags: 0x%08x\n", uFlags);
2091 /* FIXME: should test if the file is a shortcut or DOS program */
2092 if (GetFileAttributesW(pszLinkTo) == INVALID_FILE_ATTRIBUTES)
2093 return FALSE;
2095 basename = strrchrW(pszLinkTo, '\\');
2096 if (basename)
2097 basename = basename+1;
2098 else
2099 basename = pszLinkTo;
2101 lstrcpynW(pszName, pszDir, MAX_PATH);
2102 if (!PathAddBackslashW(pszName))
2103 return FALSE;
2105 dst_basename = pszName + strlenW(pszName);
2107 snprintfW(dst_basename, pszName + MAX_PATH - dst_basename, lnkformat, basename);
2109 while (GetFileAttributesW(pszName) != INVALID_FILE_ATTRIBUTES)
2111 snprintfW(dst_basename, pszName + MAX_PATH - dst_basename, lnkformatnum, basename, i);
2112 i++;
2115 return TRUE;
2118 HRESULT WINAPI SHStartNetConnectionDialog(HWND hwnd, LPCSTR pszRemoteName, DWORD dwType)
2120 FIXME("%p, %s, 0x%08x - stub\n", hwnd, debugstr_a(pszRemoteName), dwType);
2122 return S_OK;
2125 DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
2127 FIXME("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
2129 return SHFMT_NOFORMAT;
2132 /*************************************************************************
2133 * SHSetLocalizedName (SHELL32.@)
2135 HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsRes)
2137 FIXME("%p, %s, %d - stub\n", pszPath, debugstr_w(pszResModule), idsRes);
2139 return S_OK;
2142 /*************************************************************************
2143 * LinkWindow_RegisterClass (SHELL32.258)
2145 BOOL WINAPI LinkWindow_RegisterClass(void)
2147 FIXME("()\n");
2148 return TRUE;
2151 /*************************************************************************
2152 * LinkWindow_UnregisterClass (SHELL32.259)
2154 BOOL WINAPI LinkWindow_UnregisterClass(void)
2156 FIXME("()\n");
2157 return TRUE;
2160 /*************************************************************************
2161 * SHFlushSFCache (SHELL32.526)
2163 * Notifies the shell that a user-specified special folder location has changed.
2165 * NOTES
2166 * In Wine, the shell folder registry values are not cached, so this function
2167 * has no effect.
2169 void WINAPI SHFlushSFCache(void)
2173 /*************************************************************************
2174 * SHGetImageList (SHELL32.727)
2176 * Returns a copy of a shell image list.
2178 * NOTES
2179 * Windows XP features 4 sizes of image list, and Vista 5. Wine currently
2180 * only supports the traditional small and large image lists, so requests
2181 * for the others will currently fail.
2183 HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv)
2185 HIMAGELIST hLarge, hSmall;
2186 HIMAGELIST hNew;
2187 HRESULT ret = E_FAIL;
2189 /* Wine currently only maintains large and small image lists */
2190 if ((iImageList != SHIL_LARGE) && (iImageList != SHIL_SMALL) && (iImageList != SHIL_SYSSMALL))
2192 FIXME("Unsupported image list %i requested\n", iImageList);
2193 return E_FAIL;
2196 Shell_GetImageLists(&hLarge, &hSmall);
2197 hNew = ImageList_Duplicate(iImageList == SHIL_LARGE ? hLarge : hSmall);
2199 /* Get the interface for the new image list */
2200 if (hNew)
2202 ret = HIMAGELIST_QueryInterface(hNew, riid, ppv);
2203 ImageList_Destroy(hNew);
2206 return ret;
2209 /*************************************************************************
2210 * SHCreateShellFolderView [SHELL32.256]
2212 * Create a new instance of the default Shell folder view object.
2214 * RETURNS
2215 * Success: S_OK
2216 * Failure: error value
2218 * NOTES
2219 * see IShellFolder::CreateViewObject
2221 HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv,
2222 IShellView **ppsv)
2224 IShellView * psf;
2225 HRESULT hRes;
2227 *ppsv = NULL;
2228 if (!pcsfv || pcsfv->cbSize != sizeof(*pcsfv))
2229 return E_INVALIDARG;
2231 TRACE("sf=%p outer=%p callback=%p\n",
2232 pcsfv->pshf, pcsfv->psvOuter, pcsfv->psfvcb);
2234 psf = IShellView_Constructor(pcsfv->pshf);
2236 if (!psf)
2237 return E_OUTOFMEMORY;
2239 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppsv);
2240 IShellView_Release(psf);
2242 return hRes;