|
By now, you should have a better understanding of what Windows 7 libraries represent and how they can benefit users as well as developers. This is the third post in a series of Windows 7 Libraries posts. In the previous post, Understanding Windows 7 Libraries, we explained what libraries are and the important role they play in users day-to-day work. In this post, we explain the underlying architecture that supports libraries. As usual, lets start with a quick historic review of Libraries' ancestors. Windows Vista introduced a new storage scenario and a new user profile namespace called the Known Folders. This represented the next evolutionary step from standard folders that were based on a constant special item ID list (CSIDL). The CSIDL values provide a system-independent way to identify special folders used frequently by applications. In Windows Vista, we replaced these values with the Known Folders system where a KNOWNFOLDERID constant identifies each special folder. Both CSIDL and Known Folders included support for users specific content types such as Document, Music, Pictures and Videos these folders are part of the user storage profile. In Windows 7, Libraries extend some of the common user Known Folders, like My Documents, into the Documents Library. If you review the KNOWNFOLDERID in Windows 7 Beta SDK, you will find that the default Libraries are Known Folders themselves, which make sense since we want a unified programmatic way to access users content. By default, each Library contains two physical file locations:
For custom Libraries, the default save location is the first folder added. In some ways, a Library is similar to a folder. From a user's point of view, a library looks and behaves just like a regular folder. However, unlike a folder, a Library gathers files that are stored in several locations into a single view. This is a subtle, but important difference. Libraries don't actually store users items, they only monitor folders that contain items, and let users access and arrange these items in different ways. They also let users and developers access the list of folders and their contents. For example, if you try to save a text document (from Notepad) directly to the Documents Library, the file will be saved. However, we just said that Libraries are NOT regular folders that contain files, so whats going on? Well, the text file is saved to the Documents Library default save location, which is, by default, the users Documents folder also known as My Documents and is part of the user profile. The user has full control over the default save location as well as the other locations that are part of a library. As shown in the next figure, the Picture Library management dialog (which is accessible directly from the Windows Explorer UI) contains several locations on my local hard drive with one of the folders designated as the default save location. ![]() It is important to note that the Documents Library didnt replace the My Documents folder from Windows Vista; it simply includes that folder in the Pictures library as one of many locations. Also, please note that the CSIDL system and its APIs system are still supported for application compatibility. However, we do not recommend that you use them in new application development.We recommend that you use the known folder system instead A Library in Windows 7 is stored as an XML definition file that has a file extension of .library-ms. The file name is the actual librarys name. For example, the Documents Library is represented by an XML file called Documents.library-ms. Library descriptions are saved on disk in the %appdata% Roaming\Microsoft\Windows\Libraries folder (also known as FOLDERID_Libraries). You can use the Library definition files to monitor changes to the library as we will explain in future posts Lets dig into the Documents Library definition file schema. The XML structure is pretty self-explanatory, but lets explain a few of its elements. At the top of the file, we can find the Library header information: <libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library"> The root XML element is libraryDescription, which contains child elements that define the library:
Users cant change the default libraries icon via Windows Explorer, nor can they assign the icon to a new customized user-defined library. However, this can be done programmatically using the API, which we will cover in future posts. A key part of the XML is the list of locations that the Library represents: <searchConnectorDescriptionList>
One final note - Applications should never attempt to access or edit Library description files. Instead, applications should always use the Shell programming model or the IShellLibrary API to consume and manipulate Library contents. In the next post we will dive into the Shell programming model. |
0 Comments »
Windows 7
11:44 AM
0 Responses to "Libraries Under the Hood"
Post a Comment