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

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;
SHAddFolderPathToLibrary( pLib, L"C:\\temp ");
pLib ->SaveInKnownFolder(
L"Test 1 Lib",
& 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;

IShellItemArray *psiaFolders;
In the next post we will walk through some techniques of staying in sync with the library contents.


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

 Windows 7 Libraries – IShellFolder

Thread Tools

Similar help and support threads
Thread Forum
Windows 7 Libraries
Hi.Just had a re install of my C drive,I had all my documents,photos,music,video on another internal HDD the only items that were on the C drive was the operating system and programs. I was accessing my drive with the doc's etc by means of clicking on the orb and selecting what I required docs or...
General Discussion
windows libraries bar
hay can some help get rid of this bar it just showed up one day it
How do I open XP icon libraries which have libraries within them
I am new to WIN7, and have the rest of my computers running XP. I have a number of icon libraries in a folder c:\icons which contain contain icon libries within them. eg C:\icons\animals.ico contains further folders cats.ico, dogs.ico ... I have not been able to get WIN7 to open these,...
General Discussion
How do I fix my Libraries in Windows 7?
I am trying to make all my file browsing really organized so that if I ever need to retrieve a file, the process will be as streamlined as possible. However Windows Libraries are making this difficult. When I downloaded the drivers for my computer it adds several files and folders to the...
General Discussion
Windows 7 Libraries
I prefer to keep my documents on a disk separate from the operating system. In Vista, I simply move the My Documents folder to another disk. Windows 7 provides the library function allowing me to inlclude the documents on my separate disk in the documents library. However, when I install new...
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 14:09.
Twitter Facebook Google+