Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Windows 7 Libraries – IShellFolder


08 May 2009   #1

 
Windows 7 Libraries – IShellFolder

Quote:
After two weeks break, we are back to our normal technical posts, covering Windows 7 Libraries. This is the sixth post about Windows 7 Libraries. By now, you should be familiar with Windows 7 Libraries (Understanding Windows 7 Libraries) and understand the internal structure of Libraries and how they integrate into the Windows Shell (Libraries Under The Hood). You know the different programming models that are available to choose from ([LINK HERE), and you know how to use Windows Shell APIs to consume the contents of a library [link to preceding post]. In this post, we focus on the IShellLibrary COM object.

The IShellLibrary COM object presents a Windows 7 Library. This interface defines methods for creating and managing Libraries. You can work directly with the COM interface, but it's easier to use a higher abstraction layer of functions. Shobjidl.h provides the following library helper functions:

  • SHAddFolderPathToLibrary - Adds a folder to a library
  • SHCreateLibrary - Creates an IShellLibrary object
  • SHLoadLibraryFromItem - Creates and loads an IShellLibrary object from a specified library definition file
  • SHLoadLibraryFromKnownFolder - Creates and loads an IShellLibrary object for a specified KNOWNFOLDERID
  • SHLoadLibraryFromParsingName - Creates and loads an IShellLibrary object for a specified path
  • SHRemoveFolderPathFromLibrary - Removes a folder from a library
  • SHResolveFolderPathInLibrary - Attempts to resolve the target location of a library folder that has been moved or renamed
  • SHSaveLibraryInFolderPath - Saves an IShellLibrary object to disk
Note: if you are really interested in how these helper functions are implemented, simply go to the Shobjidl.h h file and search for these functions.

Using these help functions, you can perform most of the management operations on a Library without using the lower level APIs. For example, you can add a folder to a Library using SHAddFolderPathToLibrary without calling ISHellLibrary::Commit(). Since the IShellLibrary is a COM-based API, you will need to CoInitialize the COM objects. After doing so, all you need to do is use the helper functions. The following code snippet creates a new Library, adds a folder to it, and saves the Library definition file in the Libraries folder.

IShellLibrary *pLib;
IShellItem *pSi;
SHCreateLibrary(IID_PPV_ARGS(&pLib));
SHAddFolderPathToLibrary( pLib, L"C:\\temp ");
pLib ->SaveInKnownFolder(
FOLDERID_Libraries,
L"Test 1 Lib",
LSF_MAKEUNIQUENAME,
& pSi);

 
The helper functions don’t provide all the functionality in the IShellLibrary interface. By working directly with the IShellLibrary interface, you can get or set the Library icon using the GetIcon, and SetIcon. But more importantly, you can get the contents of a library by using the IShellLibrary:: GetFolders() as shown in the next code snippet


IShellLibrary *pslLibrary;
SHLoadLibraryFromKnownFolder(
FOLDERID_PicturesLibrary,
STGM_READ,
IID_PPV_ARGS(&pslLibrary));

IShellItemArray *psiaFolders;
pslLibrary->GetFolders(
LFF_FORCEFILESYSTEM,
IID_PPV_ARGS(&psiaFolders));
 
In the next post we will walk through some techniques of staying in sync with the library contents.


More...

My System SpecsSystem Spec
.

09 May 2009   #2

XP/win7 x86 build 7127
 
 

I sure wish they would address HG shares over a network with identical user/pass and why that sharing with specific users with the same user/pass on another pc on the network will not see those shares shared TO them listed under HG/library for the user created library folder. Its either share to the ENTIRE HG or dont share at all.

still want to hear the news/explanations tho, thanks z3r0
My System SpecsSystem Spec
Reply

 Windows 7 Libraries – IShellFolder




Thread Tools



Similar help and support threads for2: Windows 7 Libraries – IShellFolder
Thread Forum
Windows 7 Libraries General Discussion
windows libraries bar Customization
How do I open XP icon libraries which have libraries within them General Discussion
How do I fix my Libraries in Windows 7? General Discussion
Windows 7 Libraries/Documents General Discussion
Windows Libraries Question General Discussion
Windows 7 Libraries General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 02:35 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33