Page 1 of 1

How to get a IShellObj for "Libraries \ Pictures"?

PostPosted: Wed Apr 04, 2012 1:02 pm
by stebi
Hi,

I can get the ShellObj for "My Pictures"-Folder with that call:
Code: Select all
madShell.ShellObj(sfMyPictures)


Since Windows 7 introduced shell "libraries" and there is the default library called "pictures" I'd like to reference that. There is no predefined TSpecialFolder for that. On my machine the library has this path "::{031E4825-7B94-4DC3-B131-E946B44C8DD5}\::{A5A3563A-5755-4A6F-854E-AFA3230B199F}". I could use this string constant (if there wouldn't be another problem, see my other post), but is it the same on all computers? Is there a better way to get the library path?

Re: How to get a IShellObj for "Libraries \ Pictures"?

PostPosted: Wed Apr 04, 2012 1:12 pm
by madshi
Microsoft has added a new API set to Vista (?) which madShell does not yet use. The "special folders" supported by madShell are based on the older OS. Don't ask why MS suddenly gives up an old API and creates a new one. Anyway, I'll probably sooner or later add support for the new API to madShell, too, but it might take a while since I'm currently busy working on madExcept 4 and some other stuff.

A GUID path like that has a certain chance of being the same on all machines. If you want to make sure, search for those GUIDs in the registry to find out what they mean.

Re: How to get a IShellObj for "Libraries \ Pictures"?

PostPosted: Thu Apr 05, 2012 9:50 am
by stebi
I found a solution thanks to this post (Delphi XE2):

Code: Select all
uses
  Winapi, Winapi.KnownFolders;

var
  PIDL: PItemIDList;

Assert(Windows7);

SHGetKnownFolderIDList(FOLDERID_PicturesLibrary, 0, 0, PIDL);
try
  ...
finally
  ILFree(PIDL);
end;

Documentation can be found here: http://msdn.microsoft.com/en-us/library/bb762187(v=vs.85).aspx

Re: How to get a IShellObj for "Libraries \ Pictures"?

PostPosted: Thu Apr 05, 2012 10:59 am
by madshi
Yeah, that's the new API I mentioned earlier. Make sure you don't statically link to it, if you still want to support XP.

Re: How to get a IShellObj for "Libraries \ Pictures"?

PostPosted: Thu Apr 05, 2012 1:01 pm
by stebi
In XE2 (Winapi.ShlObj) SHGetKnownFolderIDList is declared as "delayed", so it should be no problem on older OS.

Re: How to get a IShellObj for "Libraries \ Pictures"?

PostPosted: Thu Apr 05, 2012 1:44 pm
by madshi
Didn't even know that XE2 supports "delayed"... :D I'm supporting all Delphi versions down to Delphi 4, so I couldn't do it this way. But of course dynamic linking is not a problem, so it's easily doable.

Re: How to get a IShellObj for "Libraries \ Pictures"?

PostPosted: Thu Apr 05, 2012 2:18 pm
by stebi
"delayed" came with Delphi 2010.