Hi,
Hi Stefan,
On Wednesday 25 May 2005 18:13, Stefan Dösinger wrote:
Any suggestions to the following patch?
- SHELL32_GetItemAttributes (_IShellFolder_ (This), This->pidlRoot,
&dwAttributes);
This->pidlRoot is the ITEMIDLIST of all SHITEMIDs starting from the root of the shell namespace up to the current folder. If you take a look into SHELL32_GetItemAttributes, it calls _ILIsDrive, _ILGetGUIDPointer and the like on the pidl. Those function inspect the first SHITEMID in the ITEMIDLIST only (see pidl.c). This means they will inspect the SHITEMID which represents the drive, which the ITEMIDLIST ist based on.
Just a question if I understood that correctly So PidlRoot represents a list of Folders, from the root to the current folder. For C:\somedir\dirx this would more or less mean C:\ somedir\ dirx\ (or even starting from Desktop. Msdn somewhere mentiones the Shell namespace)
What you really need to do is to call SHBindToParent. This will give you a pointer to the current folders parent folder as well as the last SHITEMID of the ITEMIDLIST. Call SHELL32_GetItemAttributes with the parent folder and this last SHITEMID.
Can I use pidlRoot(passed by the function caller) for SHBindToParent? Now I have SHBindToParent(This->pidlRoot, &IID_IShellFolder, (LPVOID*)&psfParent, (LPCITEMIDLIST*)&rpidl);
later I call SHELL32_GetItemAttributes with SHELL32_GetItemAttributes (psfParent, rpidl, (DWORD *) &This->dwAttributes);
This causes I crash. If I understand correctly, I have to set the flags I want to test in This->dwAttributes before I call SHELL32_GetItemAttributes. If I set it to 0xffffffff(I want to test for all flags) of all flags listed as supported flags in shfolder.c, I get 0xf0000144(the flags a drive supports, oh, surprise) every time and a stack overflow later on.
As to the caching of the file attributes: Those are already cached in the SHITEMID (see _ILGetFileAttributes in pidl.c). So you are adding a redundant level of caching and thus unnecessary complexity. IMHO it would be better to remove the IGenericFSImpl's dwAttributes member and just call SHELL32_GetItemAttributes.
You mean that I can pass &This->dwAttributes directly to SHELL32_GetItemAttributes?
Thanks for your help, Stefan
PS: A summary of the relevan lines: (The modified function is IFSFldr_PersistFolder3_InitializeEx)
hr = SHBindToParent(This->pidlRoot, &IID_IShellFolder, (LPVOID*)&psfParent, (LPCITEMIDLIST*)&rpidl); if(SUCCEEDED(hr)) { This->dwAttributes = 0xffffffff;
SHELL32_GetItemAttributes (psfParent, rpidl, (DWORD *) &This->dwAttributes); ERR("Attribs: 0x%08lx\n", (DWORD) This->dwAttributes); } else This->dwAttributes = 0;
This->PidlRoot is set by existing code to ILClone (pidlRoot), and pidlRoot is a parameter to the function.