Write problem with MS Office 2003

Michael Jung mjung at iss.tu-darmstadt.de
Wed May 25 16:52:43 CDT 2005


On Wednesday 25 May 2005 20:38, Stefan Dösinger wrote:
> 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\

Yes, that's correct.

> Can I use pidlRoot(passed by the function caller) for SHBindToParent? Now I
> have
> SHBindToParent(This->pidlRoot, &IID_IShellFolder, (LPVOID*)&psfParent,
> (LPCITEMIDLIST*)&rpidl);

Looks good to me.

> later I call SHELL32_GetItemAttributes with SHELL32_GetItemAttributes
> (psfParent, rpidl, (DWORD *) &This->dwAttributes);

This should work, but you should do this in GetAttributesOf and not in 
Intialize[Ex], passing the rfgInOut parameter instead of &This->dwAttributes. 
See below.

> This causes I crash. 

Ooops, no idea. Sorry. Could you send me the complete diff? 

> 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.

If you use rfgInOut you don't have to set dwAttributes to 0xffffffff. The 
caller specifies, which flags it is interested in.

> > 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?

I meant that you should remove the dwAttributes member from IGenericFSFolder 
and call SHELL32_GetItemAttributes in shfldr_fs's GetAttributesOf method 
passing the rfgInOut parameter. You don't have to modify the Initialize[Ex] 
methods.

That said, this is the preferable option in my opinion. At the end of the day, 
it's up to you (or in effect Alexandre).

> 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.

I don't see why this should crash (also I think that it belongs in 
GetAttributesOf instead of InitializeEx). Oh, perhaps I know the reason for 
the crash: Do you do the same stuff in Initialize (the non 'Ex' versions). If 
not and the shellfolder is initialized via 'Initialize' instead of 
'InitializeEx' the value of the dwAttributes is basically random, which might 
cause a crash. Nevertheless, if you move it to GetAttributes of, those are of 
course non problems.

Bye,
-- 
Michael Jung
mjung at iss.tu-darmstadt.de




More information about the wine-devel mailing list