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: Libraries Under the Hood

14 Apr 2009   #1
z3r010

 
Libraries Under the Hood

Quote:
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, let’s 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 user’s content. By default, each Library contains two physical file locations:

  • The user's personal folder by type (Documents, Pictures, Video…), which is represented by the default Known Folder that is included in a Library (that is, My Documents in the Documents Library), and it is also the default save location.
  • The public folder by type
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 what’s going on? Well, the text file is saved to the Documents Library default save location, which is, by default, the user’s 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 didn’t 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 library’s 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

Let’s dig into the Documents Library definition file schema. The XML structure is pretty self-explanatory, but let’s explain a few of its elements. At the top of the file, we can find the Library “header” information:


@shell32.dll,-34575
S-1-5-21-2127521184-1604012920-1887927527-4897363
4
true
imageres.dll,-1002

{7D49D726-3C21-4F05-99AA-FDC2C9474656}



The root XML element is libraryDescription, which contains child elements that define the library:
  • is an element that defines the Security ID of the user who created this library to isolate Libraries and protect user data from other users
  • is a Boolean element that defines if the library is pinned to the left navigation pane in Windows Explorer and NOT to the Taskbar
  • defines the content version of this library, which reflects the number of times the library definition file has been changed
  • is an optional container element that lets the author specify the folder type (Documents, Pictures, Video) for controlling the arrangements of views in Windows Explorer
  • defines an icon resource using standard Windows Shell resource style; for example: C:\Windows\system32\imageres.dll,-65 . This icon presents the library in the Windows Explorer
Users can’t 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:



@shell32.dll,-34577
true
true

knownfolder:{FDD39AD0-238F-46AF-ADB4-6C85480369C7}
MBAAAE….

  • contains one or more search connectors that map to physical locations included in this library
  • contains a element that describes one location included in the library
  • defines a URL for this location and it is there for human-readability only, this cannot be used by developers since it is likely to be out of date.
  • this is the actual representation (Base64) of a location in a library which is as a serialized ShellLink object
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.


More...


My System SpecsSystem Spec
.
14 Apr 2009   #2
johnwillyums

Windows 7 Home Premium 64 bit
 
 

That's great . Thanks. I'm a bit tired now but I think I'll read the other stuff on this when I'm fresher.
I had an idea that something like this was going on from the way my various media files on different drives seem to be aligning themselves in W7 in terms of access.
What a great OS. I can't wait for the real deal (or the RC).
I'm one of those people who doesn't bother with tech stuff unless I need to and I don't know Vista as well as I should after a couple of years of using it.
Couple of weeks with W7 and I'm feeling that this is very slick and intuitive.

Thanks for an interesting post, John
My System SpecsSystem Spec
14 Apr 2009   #3
LePoilu

Vista H.P. SP1 x32 Seven RC x64
 
 

Interesting topic.

I still ask myself what the better way for using Libraries.

For now I allways change default location of "My docs", "My musics", "Favorites" & cie (as windows allow that via 2-3 clics), for the place I save my files (like D:\documents)
But with libraries I'm asking: why just not put my location of docs in the libraries and let the default location for Docs & Cie. ?

I think .. I need to see how the software will work with libraries. If it's well supported by futur "seven compliant soft" it could be great, in other way... the older trick will still be usefull
My System SpecsSystem Spec
.

14 Apr 2009   #4
baarod

El Capitan / Windows 10
 
 

Quote   Quote: Originally Posted by LePoilu View Post
Interesting topic.

I still ask myself what the better way for using Libraries.

For now I allways change default location of "My docs", "My musics", "Favorites" & cie (as windows allow that via 2-3 clics), for the place I save my files (like D:\documents)
But with libraries I'm asking: why just not put my location of docs in the libraries and let the default location for Docs & Cie. ?

I think .. I need to see how the software will work with libraries. If it's well supported by futur "seven compliant soft" it could be great, in other way... the older trick will still be usefull
Hairy fellow, I suggest you read this post where I explore that very issue in some depth:

Windows 7 Libarary Question
My System SpecsSystem Spec
14 Apr 2009   #5
LePoilu

Vista H.P. SP1 x32 Seven RC x64
 
 

Quote   Quote: Originally Posted by baarod View Post
Hairy fellow, I suggest you read this post where I explore that very issue in some depth:

Windows 7 Libarary Question

At this time it's exactly what I've done

I just asked myself of the benefit of changing default location of "docs files" as libraries allow us to point them really clickly. But tought that third-parts soft need to be updated for a good integration of libraries
My System SpecsSystem Spec
14 Apr 2009   #6
Barman58

Windows 10 Pro x64 x2 Windows 10 Enterprise x64, Ubuntu
 
 

A major advantage of pointing your Shell folders to their location on other than a system partition is that any application that has a vista/XP aware default save location will save automatically to the remote location without user intervention.

This can be usefull for "blind" saves without a prompt or when the user forgets to re-direct the save.



My System SpecsSystem Spec
Reply

 Libraries Under the Hood




Thread Tools




Similar help and support threads
Thread Forum
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
under the hood of Win7 libraries
I'm looking for someone who understands what happens under the hood. After reading numerous articles on the Win7 libraries, I think I understand what happens under the hood. I would like to receive confirmation or correction of my perception of the details. I am not 100% sure I have the jargon...
General Discussion
Libraries
Hello, I've Created a new Partition of 35GB, I used to have all my music/Documents in the Library which is under the C:/ directory. Now I want to use my new Directory (K:/) to store all my documents but how can I use it ? I meant if I want to add new photos or Videos they'll still be in the...
General Discussion
What Changes Have Been Made Under the Hood?
I've been looking around for information about Windows 7 in regards to what changes have been made to the core OS. Most of my searches end with an article about the user interface changes and it might briefly skim over the more technical aspects. I'm looking for information more along the lines...
General Discussion
Libraries : the way it should be
Hi I thought something about libraries and the way it work on Seven. I like the concept, and I think they really have to push in this way. But at this time Library feature goes not totally where it should be. Today when you launch Seven for the first time libraries includes old default...
General Discussion
Windows 7-Under the Hood
Whats really happening when you boot your Windows 7
Chillout Room


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 23:17.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App