The virtual folder works in Windows Vista or better.
This is a sample that uses a set of C++ classes I wrote to help create
Windows Shell Namespace Extensions.
Shell Extensions (NSE) are plugins for Windows Explorer and they enable you
to extend Explorer with virtual folders, such as the current Windows implementation
of the Recycle Bin and Zip compressed folders (where you can navigate into a zip file
and browse its contents).
Shell Extensions can extend Explorer in several ways, such as adding new menuitems, Property Sheet pages or assign preview handlers to a file extension. In addition, you can create new virtual folders that act like regular file-system folders, but display items (files) that reside on a completely different media.
In the Registry folder you can browse and edit values of the registry under the
HKEY_CURRENT_USER branch (or
HKEY_LOCAL_MACHINE if you
launch Explorer under the Administrator account). And while you can also create new
keys and values just like the RegEdit tool, you may not find it much
easier to work with. It's a programming example; it's purpose is to demonstrate how
to create a virtual folder in Windows Explorer.
|This tool allows editing the Windows Registry. This is a potentially hazardous operation which could, if done incorrectly, render your system unbootable. If this happens you will have to restore a registry backup or reinstall Windows. Do not install this tool for editing the Windows Registry unless you know what you are doing.|
Once installed, you can access the My Computer folder from the Windows Start Menu (through the button named Computer).
The Source CodeQuite a long time ago I wrote a sample Shell Extension that unfolded the Amiga Disk File format as a virtual drive inside Windows Explorer. When a co-worker some time after challenged me to write a similar NSE for a mail service I started the task of cleaning up the code and write a generic NSE framework. Unfortunately due to GMail Drive becoming a somewhat popular tool, the cleanup project got side-tracked and was never completed. And so this is my 2nd attempt to get a project going to encapsulate NSE functionality in generic C++ classes.
These classes are designed to run on Windows Vista or better, mostly because Vista
offers a number of new useful APIs to help create Shell Namespace Extensions. With Windows Vista
the focus is no longer on just to provide a virtual hierarchy, but to expose properties
for your items so users can do interesting things with them.
This sample creates a virtual "file-system" around the Windows System Registry. Creating a Registry NSE is almost a mandatory programming exercise when you are new to Shell Extensions, because the Registry is usually a familiar API and it has the same tree structure as a disk file-system.
This set of C++ classes can be used to create simple Shell Extensions such as this Registry
extension, but later on I will show how to write a
file-class NSE, and also
a virtual file-system around an online storage.
It is not a particular simple framework. It kind of gets a little gnarly when you want to preserve some of the rich functionality that a versatile NSE can offer. For a custom NSE like this Registry folder you will have to implement many of the methods of the Registry Key and Registry Value classes. For a NSE that emulates a virtual file-system with actual files, my classes offer a default implementation that handles much of the trivial operations.
Shell classesThe classes provide a default implementation of several of the needed COM objects that make up even a complex Shell Extension. This includes managing the list view, menus and command buttons in the command area, Property Sheet pages and drag'n'drop operations.
To expose functionality you must implement at least 3 of these 4 classes:
This class has the same function as the ATL Module class: to provide a few functions at global scope, to assist with registration during installation and to get the virtual file-system booted.
This class expose a class factory for creating the root item of the virtual folder. In addition you can store state that is global for the entire file-system here.
This interface is the base for both virtual folders and items (files). The NSE Item class is the most important and has several methods that must be implemented and several that are optional.
In its basic form, it takes a PIDL (binary structure from the Shell) and serializes it to its own data structure, then does one or more operations on that item and serializes it back to PIDL data for the Shell.
If your shell extension exposes virtual files, you'll need a way for the Shell to read and write the contents of the files. The stream class does that. You don't need to implement this class if you don't want to support a copy operation.
This is a default item implementation. It provides stubs for all the optional methods so the actual derived implementation can concentrate on filling out the code for item functionality.
Use this default implementation as a base for your derived class when an item represents a virtual file-system file or folder. The class is based on the
WIN32_FIND_DATAstructure and publishes default properties, columns and Property Sheet pages, leaving it up to you only to retrieve the file-cache and file streams to read and write files.
Shell ConfigurationIn the file-system class, the methods
GetConfigStrallows you to control how your Shell Extension functions.
Return where you wish the Shell Extension to be located. Possible values are the MyComputer folder, the Desktop and various other shell folders. Alternatively you can define your Shell Extension as being of a file-class type.
SFGAOflags for the root folder. These flags define how the Shell Extension is perceived by the outside world. For instance, it controls whether your NSE is visible in the FileOpen and FileSave dialogs.
This Shell Extension is not able to enumerate (list) its virtual files quickly and the enumeration may take place on a different thread.
This Shell Extension may not be able to copy (extract) virtual files quickly and some file operations are expected to be slow.
The Shell Extension shows a Progress dialog when it is doing file operations since they are expected to take a long time to finish.
The Shell Extension will use the standard Windows security prompt when trying to launch a virtual file that might be unsafe.
This Shell Extension is able to receive the
SendTodesktop integration. The Send To menu is invoked by the user by selecting a files and choosing the
Send To -> My XYZ Foldermenuitem from the right-click menu.
This Shell Extension will support the
ShellNewdesktop integration. The Shell New menu is invoked by the user on a folder, choosing the
New -> My XYZ Foldermenuitem from the right-click menu.
This Shell Extension will provide Property Sheet pages for its root folder and all the items, including sub-folders.
This Shell Extension will publish custom properties to be shown in the Explorer Details panel or the Search engine.
The Shell Extension's root can act a drop-target. Dropping files on its root folder item will copy files to the top folder.
The Shell Extension extends the root context menu.
You provide a menu to the system by handing it a regular
This Shell Extension overrides the default tooltip display text of the Windows Explorer and provides its own tip-text for all items.
This Shell Extension can override calls to
IShellFolder::GetViewObject- allowing it to provide its own shell view or other custom handler.
This Shell Extension can return icons from the System Imagelist. The
GetSysIcon()member is called, which is slightly faster than calling the usual icon retrieval for the Shell.
This Shell Extension wants to put icon overlays on its icons. Icon overlays are the little icon symbols that signify a shortcut or shared file in Windows Explorer. The
GetIconOverlay()member is called to retrieve the system overlay indexes.
This Shell Extension exposes items that look and act like regular files. When you enable this flag, you should also return
SFGAO_FILESYSANCESTORflag for the root and all the folders.
All files in a subfolder have unique filenames. Each file in a subfolder can be identified by its parsing name.
When the Shell asks if it should display the Details panel in Explorer, definitely say yes.
When the Shell asks if it should display the Details panel in Explorer, just say no.
When the Shell asks if it should display the Navigation Tree panel in Explorer, just say no.
When the Shell asks if it should display the Preview button in Explorer, just say no.
This value represents the maximum length of a filename (excluding path). This limit is enforced when renaming an item's display name.
This value represents the maximum length of a full filepath.
This string contains the legal characters that may be used in a filename.
It is possible to return
NULLto indicate all characters are possible.
This string contains the characters that cannot be used in a filename.
It is possible to return
NULLto indicate that no characters are illegal.
Source Code DependenciesWindows Vista
Microsoft Visual Studio.NET 2008
Microsoft ATL Library
See AlsoA Shell Extension for TAR files
A Shell Extension for ADF Amiga files
A virtual drive to browse Flickr photos
|Installation file (312 Kb)|
Source Code (349 Kb)