PerceivedTypes, SystemFileAssociations, and Application Registration

Whenever the Shell needs to query for file association attributes for a file type, it creates an array of registry keys. The Shell checks the following registry keys, in order of decreasing priority.

  1. User Customized Key. This key is used only if the user has customized a file extension's association to override the default. Typically this is either an application key or another ProgID.
  2. ProgID Key. This key is specified as the default value of the extension key.
  3. SystemFileAssociations Key. See below.
  4. SystemFileAssociations PerceivedType Key. See below.
  5. Base Class Key. For files, this is the ASTERISK(*) key.
  6. AllFileSystemObjects Key. All files and file folders.

PerceivedTypes

PerceivedTypes are similar to file types except they refer to broad categories of file format types, rather than specific file types. For example, Image, Text, Audio, and Compressed are PerceivedTypes. File types (generally public file types) can also have a PerceivedType, and should always be defined as such when appropriate. For example, the image file types .bmp, .png, .jpg and .gif are also of PerceivedType Image.

The system defines several PerceivedTypes in Microsoft Windows XP. These include the following:

  • Image
  • Text
  • Audio
  • Video
  • Compressed
  • System

The SystemFileAssociations key under HKEY_CLASSES_ROOT stores PerceivedTypes. For example, the PerceivedType text appears as follows:

HKEY_CLASSES_ROOT

SystemFileAssociations

text

shell

edit

  • command

open

  • command

A file type's perceived type is indicated by including a PerceivedType registry string in the file type's key and specifying the perceived type. For example, to include .cpp files as PerceivedType text, you enter the following:

HKEY_CLASSES_ROOT

  • .cpp

SystemFileAssociations

The SystemFileAssociations keys exist to guarantee that Shell extensions are installed regardless of the current default ProgID or user customization. These keys enable Windows XP to define fallback attributes for file types and enable shared file associations. Supplemental verbs should be added under SystemFileAssociations .

Application Registration

When the ShellExecute function is provided with the name of an executable file in its lpFile parameter, there are several places that it can look in an attempt to find the file, including the following:

  • The current working directory
  • The Windows directory (no subdirectories are searched)
  • The Windows\System32 directory
  • Directories listed in the PATH environment variable
  • The App Paths registry key

The order that those locations are searched varies, though the App Paths key is preferred in Windows XP Service Pack 1 (SP1). The keys found under App Paths are used primarily for the following two purposes.

  • To map the name of an application's executable file to the file's fully qualified path.
  • To append information to the PATH environment variable on a per-application, per-process basis.

To provide this functionality for your application, add a subkey with the same name as your executable file to the App Paths key as follows:

HKEY_LOCAL_MACHINE

SOFTWARE

Microsoft

Windows

CurrentVersion

App Paths

  • file.exe

Note  The file name can be provided without its .exe extension. The ShellExecute function adds the extension if necessary when searching App Paths .

If a key matching the file name is found, the Shell can perform two actions. First, the (Default) value can be used as the file's fully-qualified path. Second, the Path value for that key can be appended to the end of that process' PATH environment variable. If that functionality is not required, the Path value can be omitted.

DropTarget is a REG_SZ value containing the class identifier (CLSID) of an object—usually a local rather than in-process server—that implements IDropTarget. By default, when the target is an executable file, the Shell converts the list of dropped files into a command line parameter passed to ShellExecute in its lpParameters parameter. There are several potential issues that can arise from this.

  • The Shell limits the length of a command line to MAX_PATH * 2 characters. If there are a lot of files or their particular paths are long, file names later in the list can be lost.
  • Some applications do not accept multiple file names in a command line.
  • Applications that accept multiple file names do not have a standardized file name format that they accept. The Shell provides the parameter list as a quoted string, but some applications might require strings without quotes.
  • Not all items that can be dragged are part of the file system—printers, for example. These items do not have a standard Win32 path, so there is no way to provide a meaningful lpParameters value to ShellExecute.

Using the DropTarget value avoids these issues by giving access to all of the clipboard formats, including CFSTR_SHELLIDLIST (for long file lists) and CFSTR_FILECONTENTS (for non-file system objects).

In addition to the three values recognized by the Shell, an application can also add custom values to its key to use as needed.

Applications are encouraged to use the App Paths key to provide an application-specific path rather than adding to the global system path.