bool MoveNext() { bool fMoreItems = false; if (SUCCEEDED(_hr)) { if (NULL == _pidlRel) { fMoreItems = true; _pidlRel = _pidlFull; // First item - Might be empty if it is the desktop } else if (!ILIsEmpty(_pidlRel)) { PCUITEMID_CHILD pidlChild = (PCUITEMID_CHILD)_pidlRel; // Save the current segment for binding _pidlRel = ILNext(_pidlRel); // If we are not at the end setup for the next iteration if (!ILIsEmpty(_pidlRel)) { const WORD cbSave = _pidlRel->mkid.cb; // Avoid cloning for the child by truncating temporarily _pidlRel->mkid.cb = 0; // Make this a child IShellFolder *psfNew; _hr = _psfCur->BindToObject(pidlChild, NULL, IID_PPV_ARGS(&psfNew)); if (SUCCEEDED(_hr)) { _psfCur->Release(); _psfCur = psfNew; // Transfer ownership fMoreItems = true; } _pidlRel->mkid.cb = cbSave; // Restore previous ID size } } } return fMoreItems; }
static void update_path_box(explorer_info *info) { COMBOBOXEXITEMW item; COMBOBOXEXITEMW main_item; IShellFolder *desktop; IPersistFolder2 *persist; LPITEMIDLIST desktop_pidl; IEnumIDList *ids; ImageList_Remove((HIMAGELIST)info->icon_list,-1); SendMessageW(info->path_box,CB_RESETCONTENT,0,0); SHGetDesktopFolder(&desktop); IShellFolder_QueryInterface(desktop,&IID_IPersistFolder2,(void**)&persist); IPersistFolder2_GetCurFolder(persist,&desktop_pidl); IPersistFolder2_Release(persist); persist = NULL; /*Add Desktop*/ item.iItem = -1; item.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_LPARAM; item.iIndent = 0; create_combobox_item(desktop,desktop_pidl,info->icon_list,&item); item.lParam = (LPARAM)desktop_pidl; SendMessageW(info->path_box,CBEM_INSERTITEMW,0,(LPARAM)&item); if(ILIsEqual(info->pidl,desktop_pidl)) main_item = item; else CoTaskMemFree(item.pszText); /*Add all direct subfolders of Desktop*/ if(SUCCEEDED(IShellFolder_EnumObjects(desktop,NULL,SHCONTF_FOLDERS,&ids)) && ids!=NULL) { LPITEMIDLIST curr_pidl=NULL; HRESULT hres; item.iIndent = 1; while(1) { ILFree(curr_pidl); curr_pidl=NULL; hres = IEnumIDList_Next(ids,1,&curr_pidl,NULL); if(FAILED(hres) || hres == S_FALSE) break; if(!create_combobox_item(desktop,curr_pidl,info->icon_list,&item)) WINE_WARN("Could not create a combobox item\n"); else { LPITEMIDLIST full_pidl = ILCombine(desktop_pidl,curr_pidl); item.lParam = (LPARAM)full_pidl; SendMessageW(info->path_box,CBEM_INSERTITEMW,0,(LPARAM)&item); if(ILIsEqual(full_pidl,info->pidl)) main_item = item; else if(ILIsParent(full_pidl,info->pidl,FALSE)) { /*add all parents of the pidl passed in*/ LPITEMIDLIST next_pidl = ILFindChild(full_pidl,info->pidl); IShellFolder *curr_folder = NULL, *temp; hres = IShellFolder_BindToObject(desktop,curr_pidl,NULL, &IID_IShellFolder, (void**)&curr_folder); if(FAILED(hres)) WINE_WARN("Could not get an IShellFolder\n"); while(!ILIsEmpty(next_pidl)) { LPITEMIDLIST first = ILCloneFirst(next_pidl); CoTaskMemFree(item.pszText); if(!create_combobox_item(curr_folder,first, info->icon_list,&item)) { WINE_WARN("Could not create a combobox item\n"); break; } ++item.iIndent; full_pidl = ILCombine(full_pidl,first); item.lParam = (LPARAM)full_pidl; SendMessageW(info->path_box,CBEM_INSERTITEMW,0,(LPARAM)&item); temp=NULL; hres = IShellFolder_BindToObject(curr_folder,first,NULL, &IID_IShellFolder, (void**)&temp); if(FAILED(hres)) { WINE_WARN("Could not get an IShellFolder\n"); break; } IShellFolder_Release(curr_folder); curr_folder = temp; ILFree(first); next_pidl = ILGetNext(next_pidl); } memcpy(&main_item,&item,sizeof(item)); if(curr_folder) IShellFolder_Release(curr_folder); item.iIndent = 1; } else CoTaskMemFree(item.pszText); } } ILFree(curr_pidl); IEnumIDList_Release(ids); } else WINE_WARN("Could not enumerate the desktop\n"); SendMessageW(info->path_box,CBEM_SETITEMW,0,(LPARAM)&main_item); CoTaskMemFree(main_item.pszText); }
STDAPI _IEBindToObjectInternal(BOOL fStrictBind, LPCITEMIDLIST pidl, IBindCtx * pbc, REFIID riid, void **ppvOut) { IShellFolder *psfTemp; HRESULT hr; *ppvOut = NULL; BOOL fIsUrlChild = IsURLChild(pidl, TRUE); if (fIsUrlChild || ILIsRooted(pidl)) { hr = _GetRoot(pidl, fIsUrlChild, &psfTemp); if (SUCCEEDED(hr)) { pidl = _ILNext(pidl); if (!ILIsEmpty(pidl)) hr = psfTemp->BindToObject(pidl, pbc, riid, ppvOut); else hr = psfTemp->QueryInterface(riid, ppvOut); psfTemp->Release(); } } else { // non integrated browser mode will succeed on // BindToObject(IID_IShellFolder) even for things that should // fail (files). to avoid the down stream problems caused by this we // filter out things that are not "browseable" up front, // // NOTE: this does not work on simple PIDLs DWORD dwAttribs = SFGAO_FOLDER | SFGAO_BROWSABLE | SFGAO_FILESYSTEM; hr = _IEGetAttributesOf(pidl, &dwAttribs, fStrictBind); if (SUCCEEDED(hr)) { switch (_ShouldDocObjBind(dwAttribs, fStrictBind)) { case SHOULDBIND_DOCOBJ: { // // shortcircuit and bind using our CDocObjectFolder for // files which are BROWSABLE. Without this code, file: // to non-Docobject files (such as multi-media files) // won't do anything. // // is is needed for non integraded browser mode // CDocObjectFolder *pdof = new CDocObjectFolder(); TraceMsg(TF_URLNAMESPACE, "IEBTO(%x) using DocObjectFolder", pidl); if (pdof) { hr = pdof->Initialize(pidl); if (SUCCEEDED(hr)) hr = pdof->QueryInterface(riid, ppvOut); pdof->Release(); } else hr = E_OUTOFMEMORY; } break; case SHOULDBIND_DESKTOP: { // // This is the normal case. We just bind down through the desktop... // TraceMsg(TF_URLNAMESPACE, "IEBTO(%x) using Desktop", pidl); hr = SHGetDesktopFolder(&psfTemp); if (SUCCEEDED(hr)) { // BRYANST: 7/22/97 - NT Bug #188099 // shell32.dll in IE4 SI and only in that version had a bug if pbc was passed // to IShellFolder::BindToObject() (fstreex.c!FSBindToFSFolder), it would fail // to bind to Shell Extensions that extended file system folders, such as: // the history folder, the occache, etc. We work around this by passing a NULL pbc // if the destination is an IE4 shell32.dll and it will go thru FSBindToFSFolder(). if (pbc && ShouldWorkAroundBCBug(pidl)) { pbc = NULL; } hr = psfTemp->BindToObject(pidl, pbc, riid, ppvOut); psfTemp->Release(); } } break; default: hr = E_FAIL; } } } }
bool Path::empty () const { return (ILIsEmpty(myBackend)); }