Skip to content

Plugging into Windows

Dijji edited this page Nov 2, 2017 · 2 revisions

This page goes into more detail about the Windows technology involved, and describes how this package plugs into it.

Let's begin with alternate streams. An NTFS file has multiple streams. The only one we ever normally think about is the one that holds the obvious file contents, such as the text in this document. This is held in the default stream, which has no name. NTFS also allows a file to have any number of named alternate streams. These are just as much a part of the file as the default stream, and so are moved about when the file is moved about. Note, however, that the disk space they use does not show up in the file size number. They are relatively little used. A rare example is the use of an alternate stream to hold the marker that says that a file has been downloaded from the Internet and that the user should be warned before trusting it. You can see the thinking here: it would be okay if the information were lost on a subsequent movement. If you want to see whether alternate streams are contained in your files, then I recommend Mark Russinovich’s Streams utility, downloadable here: http://technet.microsoft.com/en-us/sysinternals/bb897440.aspx.

The next idea we need is that of a property storage. This is a storage for a set of named, typed properties with a standard interface, originally specified for the OLE document format. NTFS implements this interface, and the implementation uses one or more alternate streams to physically store the properties.

Now we need to consider how Windows Explorer accesses metadata properties associated with the files that it is displaying. This mechanism was revamped and standardised In Windows Vista, and this package depends on the revised support, which allows Explorer to consume metadata properties from any source implementing a standard interface. And happily, this is the selfsame standard interface implemented by NTFS to support property storages. It should be becoming clear why the core executable of this package is only 17K.

Finally, there are the plug points related to file extensions. When Explorer wants file properties, it looks for Property Handlers associated with the file type. A property handler is just a COM DLL that implements the above-mentioned property interface (IPropertyStore), and also an interface that allows Explorer to specify the file it’s interested in (IInitializeWithFile). A property handler implementing these interfaces and passing the IPropertyStore invocations on to the NTFS implementation is the core of this package.

Also associated with the file type are lists specifying which of the more than 600 standard properties are included in the file type’s metadata. This package deals with two lists: PreviewDetails, which controls what metadata properties are shown in the preview panel; and FullDetails, which controls what metadata properties are shown in the Details tab of the Properties dialog.

This package also provides a Context Menu Handler. When Explorer finds one of these associated with a file type, it calls it to add file type specific entries to the pop-up menu shown on right click. The provided context menu handler adds menu entries to export, import and delete alternate stream metadata. To summarise, this package plugs into Windows at the following points:

  1. A DLL providing a property handler is registered as a COM server.
  2. A DLL providing a context menu handler is registered as a COM server.
  3. Registry entries are added per file extension for which metadata is to be added to link them to the property handler.
  4. Registry entries are added per file extension for which metadata is to be added to link them to the context menu handler.
  5. Registry entries are added per file extension for which metadata is to be shown to specify the properties to be shown in the preview panel (PreviewDetails) and properties dialog (FullDetails). For the next level of detail about each of the executable components which make up the package, see: