Libraries Under the Hood

z3r010

Administrator
Staff member
Local time
10:38 PM
Messages
53,449
Location
Douglas, Isle of Mam
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.


aggbug.aspx

More...
 

My Computer

Computer type
PC/Desktop
OS
Windows 11
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:D
 

My Computer

Computer Manufacturer/Model Number
The Monolith. 3.1
OS
Windows 7 Home Premium 64 bit
CPU
i7 [email protected]
Motherboard
Gigabyte Z77-D3H
Memory
2x4GB Corsair Vegeance DDR3
Graphics Card(s)
XFX GTX 260 Black Edition
Sound Card
none-through large stereo hi fi
Monitor(s) Displays
Croosover 27MDP LED IPS Dell 2408 WFP
Screen Resolution
2560x1440 1920x1200
Hard Drives
1x Samsung 840Pro 128GB SSD
1x Samsung Spinpoint F1 1TB
PSU
Corsair AX 850 Watt
Case
Cooler Master ACTS 840
Cooling
Be Quiet! Dark Rock Pro
Keyboard
Enermax Aurora
Mouse
Logitech Ballmouse
Internet Speed
20MBPS
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 Computer

OS
Vista H.P. SP1 x32 Seven RC x64
CPU
Q6600 @ 3.4Ghz
Motherboard
GA-EP45-DS3L
Memory
4Go PC2-6400
Graphics Card(s)
8500GT @ 700/500
Sound Card
Audigy Platinium
Monitor(s) Displays
Mitsubishi Diamond Pro 920 + Mitsubishi Diamond Pro 720
Screen Resolution
1600x1200 twice
Hard Drives
Hitachi 160Go
Maxtor 160Go (system drive)
Maxtor 200Go in Antec MX-1 EC external box (eSATA-USB2.0)
PSU
Corsair VX550W
Case
Thermaltake Xaser III
Cooling
Watercooling (CPU, GPU, HDD, NB)
Keyboard
MS Wireless Multimedia 6000 V2.0
Mouse
IntellEye Explorer 3.0
Internet Speed
ADSL 18Mbit/s/1Mbit/s
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:

http://www.sevenforums.com/general-discussion/1559-windows-7-libarary-question.html#post15180
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Apple
OS
El Capitan / Windows 10
CPU
i7-4980HQ
Memory
16GB
Graphics Card(s)
Iris 5200

My Computer

OS
Vista H.P. SP1 x32 Seven RC x64
CPU
Q6600 @ 3.4Ghz
Motherboard
GA-EP45-DS3L
Memory
4Go PC2-6400
Graphics Card(s)
8500GT @ 700/500
Sound Card
Audigy Platinium
Monitor(s) Displays
Mitsubishi Diamond Pro 920 + Mitsubishi Diamond Pro 720
Screen Resolution
1600x1200 twice
Hard Drives
Hitachi 160Go
Maxtor 160Go (system drive)
Maxtor 200Go in Antec MX-1 EC external box (eSATA-USB2.0)
PSU
Corsair VX550W
Case
Thermaltake Xaser III
Cooling
Watercooling (CPU, GPU, HDD, NB)
Keyboard
MS Wireless Multimedia 6000 V2.0
Mouse
IntellEye Explorer 3.0
Internet Speed
ADSL 18Mbit/s/1Mbit/s
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. :o



 

My Computers

System One System Two

  • Computer type
    PC/Desktop
    Computer Manufacturer/Model Number
    ChillBlast - Custom to my design
    OS
    Windows 11 Pro x64 [Latest Release and Release Preview]
    CPU
    Ryzen 9 5950X, 3.8 - 5.2 MHz
    Motherboard
    Asus Prime X570-Pro
    Memory
    64GB [2 x 32GB] DDR4 3200MHz
    Graphics Card(s)
    4GB NVIDIA GEFORCE GTX 1650 Ti
    Sound Card
    On-board SPDIF to 5.1 System + HDMI [5.1 system]
    Monitor(s) Displays
    32" UHD 32 Bit HDR Monitor + 43" UHD 4K 32Bit HDR TV
    Screen Resolution
    2 x 3840 x 2160 @60Hz
    Hard Drives
    1TB M2 SSD OS, 500GB Fast Access SSD, 2 x 8TB Data + Various Externals from 1TB to 4TB, 10TB NAS
    PSU
    NZXT C750 80 PLUS Gold 750W Modular PSU
    Case
    Workstation Case [Matt Black]
    Cooling
    NZXT Kraken X63 280mm CPU Cooler +2x Quiet Case fans
    Keyboard
    Logitech Wireless MX Keys & K400 + others
    Mouse
    Logitech Wireless MX Master 3S
    Internet Speed
    920 MB Down 50 MB Up
    Antivirus
    BitDefender Total Security Pro
    Browser
    Chrome (always run latest Non-Beta)
    Other Info
    Also run ...
    Laptop - Quad 8GB - Windows 10 Pro x64
    Nexus 7 Android tablet x2
    Samsung 10.2" tablet
    Blackview TAB 8 4G Android Tablet c/w Keyboard
    Wacom Intuos Pro Medium Pen Pad
    Wacom Intuos Pro Small Pen Pad
    Wacom Expresskeys Remote
    Loopdeck+ Graphics Controller
    Shuttle Pro v2 Control
  • Computer type
    Laptop
    System Manufacturer/Model Number
    Dell XPS 17 10750H
    OS
    Windows 11 Pro x64 Latest RP
    CPU
    Intel I7 10750H 5.0GHz
    Motherboard
    Dell XPS
    Memory
    32GB [2x16GB] DDR4 2933 MHz
    Graphics Card(s)
    nVidia GTX1650Ti 4 GB GDDR6
    Sound Card
    Stock [Realtek] 4 Speaker
    Monitor(s) Displays
    17" IPS UHD+ Infinity Edge Touchscreen
    Screen Resolution
    3840 x 2400
    Hard Drives
    2TB M2 NVMe, 4TB External + various 500GB & 1TB External NVMe (also have access to spinner HDD from
    PSU
    Stock
    Case
    Stock XPS Aluminium & Carbon Fibre
    Cooling
    Stock - Active Fan Control
    Keyboard
    Backlit + Various Logitech
    Mouse
    Stock Track Pad + Logitech MX Trackball
    Internet Speed
    72 MB Down 18MB Up
    Browser
    Chrome
    Other Info
    Also run ...
    Laptop - Quad 8GB - Windows 10 Pro x64
    Nexus 7 Android tablet x2
    10.2" tablet
    Sony Z3 Android Smartphone
    Wacom Intuos Pro Medium Pen Pad
    Wacom Intuos Pro Small Pen Pad
    Wacom Expresskeys Remote
    Loopdeck+ Graphics Controller
    Shuttle Pro v2 Control Pad
    10TB NAS
Back
Top