Overview

Windows 7 introduces a new concept of Libraries as the new entry point for users’ data. Where users can find and organize their data as collections of items that may span multiple locations across computers. Libraries supersede the functionality of previous Windows versions' known folders (for example, Documents, Pictures, Music) and replace them as the main “storage” destination. The Library API gives applications a straightforward method for interacting with libraries programmatically. Applications can create, interact with, and support libraries as first-class items in their environments.

With Windows 7, the concept of Libraries tries to address the problem of users storing content all over their PC by allowing them to have full control over their Documents Library folder structure. In other words, in Windows 7 users can define which folders to include in the Documents Library. We can say that Libraries are user-defined collections of folders that are logical representations of user content. By including folders in Libraries, the user is telling Windows where his or her important data is located. The system will index these folders, enabling faster searching and much richer viewing arrangement capabilities in Windows Explorer based on the file properties and metadata.

In previous versions of Windows, each application had its own proprietary library. For example, Windows Media Player had a different set of scopes than iTunes, and neither was consistent with the Music folder. With the Library API, applications can define and consume a consistent set of user-defined scopes.

Figure 1

Libraries integration with Windows Shell

Libraries may also contain network folders. This enables a better user experience at work and at home. Whenever users open a common file dialog, they get an aggregated view of all of the library locations that are available.

Note:
For more information, see Inside Windows 7: Introducing Libraries.

Objectives

In this Hands-On Lab, you will learn how to manage libraries programmatically; specifically:

  • Create a new library
  • Open an existing library
  • Add and remove folders from a library
  • Get the library’s folder list
  • Delete a library
  • Rename a library
  • Set the default save folder of a library
  • Set library properties such as Folder Type, Icon, and its Pinned To Navigation Pane state
  • Show the Shell "manage user interface" dialog

Setup

For convenience, much of the code you will be managing along this hands-on lab is available as Visual Studio code snippets. The setup needed for this lab consist on installing these snippets. To do this:

  1. Run the ShellLibrariesLab.vsi installer located under the lab's Setup folder.
  2. Follow the wizard instructions to install the snippets.

System Requirements

You must have the following items to complete this lab:

  • Microsoft Visual Studio 2008
  • Windows 7
  • The Windows API Code Pack library
    Note:
    For simplicity, you can find these assemblies under the Assets folder of this lab. If you want to dig deeper in Windows API Code Pack library source code, just download it from the link sited above.