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

delphi package - easy access to shell apis

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

Postby stebi » Wed Apr 04, 2012 1:02 pm

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?
stebi
 
Posts: 8
Joined: Mon Nov 12, 2007 5:11 pm

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

Postby madshi » Wed Apr 04, 2012 1:12 pm

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.
madshi
Site Admin
 
Posts: 9376
Joined: Sun Mar 21, 2004 5:25 pm

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

Postby stebi » Thu Apr 05, 2012 9:50 am

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
stebi
 
Posts: 8
Joined: Mon Nov 12, 2007 5:11 pm

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

Postby madshi » Thu Apr 05, 2012 10:59 am

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.
madshi
Site Admin
 
Posts: 9376
Joined: Sun Mar 21, 2004 5:25 pm

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

Postby stebi » Thu Apr 05, 2012 1:01 pm

In XE2 (Winapi.ShlObj) SHGetKnownFolderIDList is declared as "delayed", so it should be no problem on older OS.
stebi
 
Posts: 8
Joined: Mon Nov 12, 2007 5:11 pm

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

Postby madshi » Thu Apr 05, 2012 1:44 pm

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.
madshi
Site Admin
 
Posts: 9376
Joined: Sun Mar 21, 2004 5:25 pm

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

Postby stebi » Thu Apr 05, 2012 2:18 pm

"delayed" came with Delphi 2010.
stebi
 
Posts: 8
Joined: Mon Nov 12, 2007 5:11 pm


Return to madShell

Who is online

Users browsing this forum: No registered users and 1 guest

cron