Do not allow creation of not aligned EMF records by GDI code.
[wine.git] / dlls / shell32 / shfldr_mycomp.c
blob28699c85bb8e0aee40986fc5d8e20d2d0f9b828d
2 /*
3 * Virtual Workplace folder
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998, 1999, 2002 Juergen 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "config.h"
24 #include "wine/port.h"
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stdarg.h>
29 #include <stdio.h>
31 #define NONAMELESSUNION
32 #define NONAMELESSSTRUCT
33 #include "winerror.h"
34 #include "windef.h"
35 #include "winbase.h"
36 #include "winreg.h"
38 #include "wingdi.h"
39 #include "pidl.h"
40 #include "shlguid.h"
41 #include "enumidlist.h"
42 #include "undocshell.h"
43 #include "shell32_main.h"
44 #include "shresdef.h"
45 #include "shlwapi.h"
46 #include "shellfolder.h"
47 #include "wine/debug.h"
48 #include "debughlp.h"
49 #include "shfldr.h"
51 WINE_DEFAULT_DEBUG_CHANNEL (shell);
53 /***********************************************************************
54 * IShellFolder implementation
57 typedef struct {
58 ICOM_VFIELD (IShellFolder2);
59 DWORD ref;
60 ICOM_VTABLE (IPersistFolder2) * lpVtblPersistFolder2;
62 /* both paths are parsible from the desktop */
63 LPITEMIDLIST pidlRoot; /* absolute pidl */
64 int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */
65 } IGenericSFImpl;
67 static struct ICOM_VTABLE (IShellFolder2) vt_ShellFolder2;
68 static struct ICOM_VTABLE (IPersistFolder2) vt_PersistFolder2;
70 #define _IPersistFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpVtblPersistFolder2)))
71 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
74 converts This to a interface pointer
76 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
77 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
78 #define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl)
80 #define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2)
81 #define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2)
82 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2)
84 /***********************************************************************
85 * IShellFolder [MyComputer] implementation
88 static shvheader MyComputerSFHeader[] = {
89 {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
90 {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
91 {IDS_SHV_COLUMN6, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
92 {IDS_SHV_COLUMN7, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
95 #define MYCOMPUTERSHELLVIEWCOLUMNS 4
97 /**************************************************************************
98 * ISF_MyComputer_Constructor
100 HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
102 IGenericSFImpl *sf;
104 TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
106 if (!ppv)
107 return E_POINTER;
108 if (pUnkOuter)
109 return CLASS_E_NOAGGREGATION;
111 sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl));
112 if (!sf)
113 return E_OUTOFMEMORY;
115 sf->ref = 0;
116 sf->lpVtbl = &vt_ShellFolder2;
117 sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
118 sf->pidlRoot = _ILCreateMyComputer (); /* my qualified pidl */
120 if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) {
121 IUnknown_Release (_IUnknown_ (sf));
122 return E_NOINTERFACE;
125 TRACE ("--(%p)\n", sf);
126 return S_OK;
129 /**************************************************************************
130 * ISF_MyComputer_fnQueryInterface
132 * NOTES supports not IPersist/IPersistFolder
134 static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
136 ICOM_THIS (IGenericSFImpl, iface);
138 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
140 *ppvObj = NULL;
142 if (IsEqualIID (riid, &IID_IUnknown) ||
143 IsEqualIID (riid, &IID_IShellFolder) || IsEqualIID (riid, &IID_IShellFolder2)) {
144 *ppvObj = This;
145 } else if (IsEqualIID (riid, &IID_IPersist) ||
146 IsEqualIID (riid, &IID_IPersistFolder) || IsEqualIID (riid, &IID_IPersistFolder2)) {
147 *ppvObj = _IPersistFolder2_ (This);
150 if (*ppvObj) {
151 IUnknown_AddRef ((IUnknown *) (*ppvObj));
152 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
153 return S_OK;
155 TRACE ("-- Interface: E_NOINTERFACE\n");
156 return E_NOINTERFACE;
159 static ULONG WINAPI ISF_MyComputer_fnAddRef (IShellFolder2 * iface)
161 ICOM_THIS (IGenericSFImpl, iface);
163 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
165 return ++(This->ref);
168 static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface)
170 ICOM_THIS (IGenericSFImpl, iface);
172 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
174 if (!--(This->ref)) {
175 TRACE ("-- destroying IShellFolder(%p)\n", This);
176 if (This->pidlRoot)
177 SHFree (This->pidlRoot);
178 LocalFree ((HLOCAL) This);
179 return 0;
181 return This->ref;
184 /**************************************************************************
185 * ISF_MyComputer_fnParseDisplayName
187 static HRESULT WINAPI
188 ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface,
189 HWND hwndOwner,
190 LPBC pbc,
191 LPOLESTR lpszDisplayName,
192 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
194 ICOM_THIS (IGenericSFImpl, iface);
196 HRESULT hr = E_INVALIDARG;
197 LPCWSTR szNext = NULL;
198 WCHAR szElement[MAX_PATH];
199 LPITEMIDLIST pidlTemp = NULL;
200 CLSID clsid;
202 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
203 This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
205 *ppidl = 0;
206 if (pchEaten)
207 *pchEaten = 0; /* strange but like the original */
209 /* handle CLSID paths */
210 if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') {
211 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
212 TRACE ("-- element: %s\n", debugstr_w (szElement));
213 SHCLSIDFromStringW (szElement + 2, &clsid);
214 pidlTemp = _ILCreateGuid (PT_GUID, &clsid);
216 /* do we have an absolute path name ? */
217 else if (PathGetDriveNumberW (lpszDisplayName) >= 0 && lpszDisplayName[2] == (WCHAR) '\\') {
218 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
219 pidlTemp = _ILCreateDrive (szElement);
222 if (szNext && *szNext) {
223 hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
224 } else {
225 if (pdwAttributes && *pdwAttributes) {
226 SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
228 hr = S_OK;
231 *ppidl = pidlTemp;
233 TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr);
235 return hr;
238 /**************************************************************************
239 * CreateMyCompEnumList()
241 static BOOL CreateMyCompEnumList(IEnumIDList *list, DWORD dwFlags)
243 BOOL ret = TRUE;
245 TRACE("(%p)->(flags=0x%08lx) \n",list,dwFlags);
247 /*enumerate the folders*/
248 if(dwFlags & SHCONTF_FOLDERS)
250 WCHAR wszDriveName[] = {'A', ':', '\\', '\0'};
251 DWORD dwDrivemap = GetLogicalDrives();
252 HKEY hkey;
254 while (ret && wszDriveName[0]<='Z')
256 if(dwDrivemap & 0x00000001L)
257 ret = AddToEnumList(list, _ILCreateDrive(wszDriveName));
258 wszDriveName[0]++;
259 dwDrivemap = dwDrivemap >> 1;
262 TRACE("-- (%p)-> enumerate (mycomputer shell extensions)\n",list);
263 if (ret && !RegOpenKeyExA(HKEY_LOCAL_MACHINE,
264 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\explorer\\mycomputer\\NameSpace",
265 0, KEY_READ, &hkey))
267 char iid[50];
268 int i=0;
270 while (ret)
272 DWORD size = sizeof (iid);
273 LONG apiRet = RegEnumKeyExA(hkey, i, iid, &size, 0, NULL, NULL,
274 NULL);
276 if (ERROR_SUCCESS == apiRet)
278 /* FIXME: shell extensions, shouldn't the type be
279 * PT_SHELLEXT? */
280 ret = AddToEnumList(list, _ILCreateGuidFromStrA(iid));
281 i++;
283 else if (ERROR_NO_MORE_ITEMS == apiRet)
284 break;
285 else
286 ret = FALSE;
288 RegCloseKey(hkey);
291 return ret;
294 /**************************************************************************
295 * ISF_MyComputer_fnEnumObjects
297 static HRESULT WINAPI
298 ISF_MyComputer_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
300 ICOM_THIS (IGenericSFImpl, iface);
302 TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
304 *ppEnumIDList = IEnumIDList_Constructor();
305 if (*ppEnumIDList)
306 CreateMyCompEnumList(*ppEnumIDList, dwFlags);
308 TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
310 return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
313 /**************************************************************************
314 * ISF_MyComputer_fnBindToObject
316 static HRESULT WINAPI
317 ISF_MyComputer_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl,
318 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
320 ICOM_THIS (IGenericSFImpl, iface);
322 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
324 return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut);
327 /**************************************************************************
328 * ISF_MyComputer_fnBindToStorage
330 static HRESULT WINAPI
331 ISF_MyComputer_fnBindToStorage (IShellFolder2 * iface,
332 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
334 ICOM_THIS (IGenericSFImpl, iface);
336 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
338 *ppvOut = NULL;
339 return E_NOTIMPL;
342 /**************************************************************************
343 * ISF_MyComputer_fnCompareIDs
346 static HRESULT WINAPI
347 ISF_MyComputer_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
349 ICOM_THIS (IGenericSFImpl, iface);
351 int nReturn;
353 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
354 nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
355 TRACE ("-- %i\n", nReturn);
356 return nReturn;
359 /**************************************************************************
360 * ISF_MyComputer_fnCreateViewObject
362 static HRESULT WINAPI
363 ISF_MyComputer_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
365 ICOM_THIS (IGenericSFImpl, iface);
367 LPSHELLVIEW pShellView;
368 HRESULT hr = E_INVALIDARG;
370 TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), ppvOut);
372 if (ppvOut) {
373 *ppvOut = NULL;
375 if (IsEqualIID (riid, &IID_IDropTarget)) {
376 WARN ("IDropTarget not implemented\n");
377 hr = E_NOTIMPL;
378 } else if (IsEqualIID (riid, &IID_IContextMenu)) {
379 WARN ("IContextMenu not implemented\n");
380 hr = E_NOTIMPL;
381 } else if (IsEqualIID (riid, &IID_IShellView)) {
382 pShellView = IShellView_Constructor ((IShellFolder *) iface);
383 if (pShellView) {
384 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
385 IShellView_Release (pShellView);
389 TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
390 return hr;
393 /**************************************************************************
394 * ISF_MyComputer_fnGetAttributesOf
396 static HRESULT WINAPI
397 ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
399 ICOM_THIS (IGenericSFImpl, iface);
401 HRESULT hr = S_OK;
403 TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut);
405 if ((!cidl) || (!apidl) || (!rgfInOut))
406 return E_INVALIDARG;
408 if (*rgfInOut == 0)
409 *rgfInOut = ~0;
411 while (cidl > 0 && *apidl) {
412 pdump (*apidl);
413 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
414 apidl++;
415 cidl--;
418 TRACE ("-- result=0x%08lx\n", *rgfInOut);
419 return hr;
422 /**************************************************************************
423 * ISF_MyComputer_fnGetUIObjectOf
425 * PARAMETERS
426 * HWND hwndOwner, //[in ] Parent window for any output
427 * UINT cidl, //[in ] array size
428 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
429 * REFIID riid, //[in ] Requested Interface
430 * UINT* prgfInOut, //[ ] reserved
431 * LPVOID* ppvObject) //[out] Resulting Interface
434 static HRESULT WINAPI
435 ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface,
436 HWND hwndOwner,
437 UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
439 ICOM_THIS (IGenericSFImpl, iface);
441 LPITEMIDLIST pidl;
442 IUnknown *pObj = NULL;
443 HRESULT hr = E_INVALIDARG;
445 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
446 This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
448 if (ppvOut) {
449 *ppvOut = NULL;
451 if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) {
452 pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
453 hr = S_OK;
454 } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
455 pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
456 hr = S_OK;
457 } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
458 pidl = ILCombine (This->pidlRoot, apidl[0]);
459 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
460 SHFree (pidl);
461 hr = S_OK;
462 } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) {
463 pidl = ILCombine (This->pidlRoot, apidl[0]);
464 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
465 SHFree (pidl);
466 hr = S_OK;
467 } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
468 hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
469 } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
470 && (cidl == 1)) {
471 pidl = ILCombine (This->pidlRoot, apidl[0]);
472 hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
473 SHFree (pidl);
474 } else {
475 hr = E_NOINTERFACE;
478 if (SUCCEEDED(hr) && !pObj)
479 hr = E_OUTOFMEMORY;
481 *ppvOut = pObj;
483 TRACE ("(%p)->hr=0x%08lx\n", This, hr);
484 return hr;
487 /**************************************************************************
488 * ISF_MyComputer_fnGetDisplayNameOf
490 static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
492 ICOM_THIS (IGenericSFImpl, iface);
494 char szPath[MAX_PATH],
495 szDrive[18];
496 int len = 0;
497 BOOL bSimplePidl;
498 HRESULT hr = S_OK;
500 TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
501 pdump (pidl);
503 if (!strRet)
504 return E_INVALIDARG;
506 szPath[0] = 0x00;
507 szDrive[0] = 0x00;
509 bSimplePidl = _ILIsPidlSimple (pidl);
511 if (!pidl->mkid.cb) {
512 /* parsing name like ::{...} */
513 lstrcpyA (szPath, "::");
514 SHELL32_GUIDToStringA(&CLSID_MyComputer, &szPath[2]);
515 } else if (_ILIsSpecialFolder (pidl)) {
516 /* take names of special folders only if its only this folder */
517 if (bSimplePidl) {
518 GUID const *clsid;
520 if ((clsid = _ILGetGUIDPointer (pidl))) {
521 if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) {
522 int bWantsForParsing;
525 * we can only get a filesystem path from a shellfolder if the value WantsFORPARSING in
526 * CLSID\\{...}\\shellfolder exists
527 * exception: the MyComputer folder has this keys not but like any filesystem backed
528 * folder it needs these behaviour
530 /* get the "WantsFORPARSING" flag from the registry */
531 char szRegPath[100];
533 lstrcpyA (szRegPath, "CLSID\\");
534 SHELL32_GUIDToStringA (clsid, &szRegPath[6]);
535 lstrcatA (szRegPath, "\\shellfolder");
536 bWantsForParsing =
537 (ERROR_SUCCESS ==
538 SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, "WantsFORPARSING", NULL, NULL, NULL));
540 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && bWantsForParsing) {
541 /* we need the filesystem path to the destination folder. Only the folder itself can know it */
542 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
543 } else {
544 LPSTR p;
546 /* parsing name like ::{...} */
547 p = lstrcpyA(szPath, "::") + 2;
548 p += SHELL32_GUIDToStringA(&CLSID_MyComputer, p);
550 lstrcatA(p, "\\::");
551 p += 3;
552 SHELL32_GUIDToStringA(clsid, p);
554 } else {
555 /* user friendly name */
556 HCR_GetClassNameA (clsid, szPath, MAX_PATH);
558 } else
559 _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */
560 } else {
561 FIXME ("special folder\n");
563 } else {
564 if (!_ILIsDrive (pidl)) {
565 ERR ("Wrong pidl type\n");
566 return E_INVALIDARG;
569 _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */
571 /* long view "lw_name (C:)" */
572 if (bSimplePidl && !(dwFlags & SHGDN_FORPARSING)) {
573 DWORD dwVolumeSerialNumber,
574 dwMaximumComponetLength,
575 dwFileSystemFlags;
577 GetVolumeInformationA (szPath, szDrive, sizeof (szDrive) - 6, &dwVolumeSerialNumber,
578 &dwMaximumComponetLength, &dwFileSystemFlags, NULL, 0);
579 strcat (szDrive, " (");
580 strncat (szDrive, szPath, 2);
581 strcat (szDrive, ")");
582 strcpy (szPath, szDrive);
586 if (!bSimplePidl) { /* go deeper if needed */
587 PathAddBackslashA (szPath);
588 len = strlen (szPath);
590 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len);
593 if (SUCCEEDED (hr)) {
594 strRet->uType = STRRET_CSTR;
595 lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
598 TRACE ("-- (%p)->(%s)\n", This, szPath);
599 return hr;
602 /**************************************************************************
603 * ISF_MyComputer_fnSetNameOf
604 * Changes the name of a file object or subfolder, possibly changing its item
605 * identifier in the process.
607 * PARAMETERS
608 * HWND hwndOwner, //[in ] Owner window for output
609 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
610 * LPCOLESTR lpszName, //[in ] the items new display name
611 * DWORD dwFlags, //[in ] SHGNO formatting flags
612 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
614 static HRESULT WINAPI ISF_MyComputer_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
615 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
617 ICOM_THIS (IGenericSFImpl, iface);
618 FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
619 return E_FAIL;
622 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
624 ICOM_THIS (IGenericSFImpl, iface);
625 FIXME ("(%p)\n", This);
626 return E_NOTIMPL;
628 static HRESULT WINAPI ISF_MyComputer_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
630 ICOM_THIS (IGenericSFImpl, iface);
631 FIXME ("(%p)\n", This);
632 return E_NOTIMPL;
634 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
636 ICOM_THIS (IGenericSFImpl, iface);
638 TRACE ("(%p)\n", This);
640 if (pSort) *pSort = 0;
641 if (pDisplay) *pDisplay = 0;
642 return S_OK;
644 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
646 ICOM_THIS (IGenericSFImpl, iface);
648 TRACE ("(%p)\n", This);
650 if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS) return E_INVALIDARG;
651 *pcsFlags = MyComputerSFHeader[iColumn].pcsFlags;
652 return S_OK;
654 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
656 ICOM_THIS (IGenericSFImpl, iface);
657 FIXME ("(%p)\n", This);
658 return E_NOTIMPL;
661 /* FIXME: drive size >4GB is rolling over */
662 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
664 ICOM_THIS (IGenericSFImpl, iface);
665 HRESULT hr;
667 TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
669 if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS)
670 return E_INVALIDARG;
672 if (!pidl) {
673 psd->fmt = MyComputerSFHeader[iColumn].fmt;
674 psd->cxChar = MyComputerSFHeader[iColumn].cxChar;
675 psd->str.uType = STRRET_CSTR;
676 LoadStringA (shell32_hInstance, MyComputerSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
677 return S_OK;
678 } else {
679 char szPath[MAX_PATH];
680 ULARGE_INTEGER ulBytes;
682 psd->str.u.cStr[0] = 0x00;
683 psd->str.uType = STRRET_CSTR;
684 switch (iColumn) {
685 case 0: /* name */
686 hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
687 break;
688 case 1: /* type */
689 _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
690 break;
691 case 2: /* total size */
692 if (_ILIsDrive (pidl)) {
693 _ILSimpleGetText (pidl, szPath, MAX_PATH);
694 GetDiskFreeSpaceExA (szPath, NULL, &ulBytes, NULL);
695 StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH);
697 break;
698 case 3: /* free size */
699 if (_ILIsDrive (pidl)) {
700 _ILSimpleGetText (pidl, szPath, MAX_PATH);
701 GetDiskFreeSpaceExA (szPath, &ulBytes, NULL, NULL);
702 StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH);
704 break;
706 hr = S_OK;
709 return hr;
711 static HRESULT WINAPI ISF_MyComputer_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
713 ICOM_THIS (IGenericSFImpl, iface);
714 FIXME ("(%p)\n", This);
715 return E_NOTIMPL;
718 static ICOM_VTABLE (IShellFolder2) vt_ShellFolder2 =
720 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
721 ISF_MyComputer_fnQueryInterface,
722 ISF_MyComputer_fnAddRef,
723 ISF_MyComputer_fnRelease,
724 ISF_MyComputer_fnParseDisplayName,
725 ISF_MyComputer_fnEnumObjects,
726 ISF_MyComputer_fnBindToObject,
727 ISF_MyComputer_fnBindToStorage,
728 ISF_MyComputer_fnCompareIDs,
729 ISF_MyComputer_fnCreateViewObject,
730 ISF_MyComputer_fnGetAttributesOf,
731 ISF_MyComputer_fnGetUIObjectOf,
732 ISF_MyComputer_fnGetDisplayNameOf,
733 ISF_MyComputer_fnSetNameOf,
734 /* ShellFolder2 */
735 ISF_MyComputer_fnGetDefaultSearchGUID,
736 ISF_MyComputer_fnEnumSearches,
737 ISF_MyComputer_fnGetDefaultColumn,
738 ISF_MyComputer_fnGetDefaultColumnState,
739 ISF_MyComputer_fnGetDetailsEx,
740 ISF_MyComputer_fnGetDetailsOf,
741 ISF_MyComputer_fnMapColumnToSCID
744 /************************************************************************
745 * IMCFldr_PersistFolder2_QueryInterface
747 static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj)
749 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
751 TRACE ("(%p)\n", This);
753 return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj);
756 /************************************************************************
757 * IMCFldr_PersistFolder2_AddRef
759 static ULONG WINAPI IMCFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
761 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
763 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
765 return IUnknown_AddRef (_IUnknown_ (This));
768 /************************************************************************
769 * ISFPersistFolder_Release
771 static ULONG WINAPI IMCFldr_PersistFolder2_Release (IPersistFolder2 * iface)
773 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
775 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
777 return IUnknown_Release (_IUnknown_ (This));
780 /************************************************************************
781 * IMCFldr_PersistFolder2_GetClassID
783 static HRESULT WINAPI IMCFldr_PersistFolder2_GetClassID (IPersistFolder2 * iface, CLSID * lpClassId)
785 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
787 TRACE ("(%p)\n", This);
789 if (!lpClassId)
790 return E_POINTER;
791 *lpClassId = CLSID_MyComputer;
793 return S_OK;
796 /************************************************************************
797 * IMCFldr_PersistFolder2_Initialize
799 * NOTES: it makes no sense to change the pidl
801 static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize (IPersistFolder2 * iface, LPCITEMIDLIST pidl)
803 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
804 TRACE ("(%p)->(%p)\n", This, pidl);
805 return E_NOTIMPL;
808 /**************************************************************************
809 * IPersistFolder2_fnGetCurFolder
811 static HRESULT WINAPI IMCFldr_PersistFolder2_GetCurFolder (IPersistFolder2 * iface, LPITEMIDLIST * pidl)
813 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
815 TRACE ("(%p)->(%p)\n", This, pidl);
817 if (!pidl)
818 return E_POINTER;
819 *pidl = ILClone (This->pidlRoot);
820 return S_OK;
823 static ICOM_VTABLE (IPersistFolder2) vt_PersistFolder2 =
825 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
826 IMCFldr_PersistFolder2_QueryInterface,
827 IMCFldr_PersistFolder2_AddRef,
828 IMCFldr_PersistFolder2_Release,
829 IMCFldr_PersistFolder2_GetClassID,
830 IMCFldr_PersistFolder2_Initialize,
831 IMCFldr_PersistFolder2_GetCurFolder