Perceived Types and Application Registration

When the Shell queries for a file type's association attributes, the Shell creates an array of registry keys. The Shell then checks those registry keys.

This topic is organized as follows:

Perceived Types

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

Perceived type values are defined as subkeys of HKEY_CLASSES_ROOT\SystemFileAssociations . For example, the perceived type text is registered as follows:

HKEY_CLASSES_ROOT
     SystemFileAssociations
          text
               shell
                    edit
                         command
                              (Default) = "%SystemRoot%\system32\NOTEPAD.EXE" "%1"
                    open
                         command
                              (Default) = "%SystemRoot%\system32\NOTEPAD.EXE" "%1"

The system defines several default perceived types:

  • folder
  • text
  • image
  • audio
  • video
  • compressed
  • document
  • system
  • application
  • gamemedia
  • contacts

A file type's perceived type is indicated by including a PerceivedType value in the file type's subkey. The PerceivedType value is set to the name of the perceived type under HKEY_CLASSES_ROOT\SystemFileAssociations as shown in the previous registry example. For example, to include .cpp files as PerceivedType text, you enter the following:

HKEY_CLASSES_ROOT
     .cpp
          PerceivedType = text

Subkeys registered under HKEY_CLASSES_ROOT\SystemFileAssociations exist to guarantee that Shell extensions are installed regardless of the current default ProgID or user customization. These keys enable the Shell to define fallback attributes for file types and enable shared file associations. Supplemental verbs are also added under SystemFileAssociations .

Application Registration

When the ShellExecute function is called with the name of an executable file in its lpFile parameter, there are several places where it seeks the file, including the following locations:

  • The current working directory
  • The Windows directory (no subdirectories are searched)
  • The Windows\System32 directory
  • Directories listed in the PATH environment variable
  • The HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths registry subkey
Note  The order in which those locations are searched varies, although the App Paths subkey is preferred on computers running Windows XP Service Pack 1 (SP1) and later.

The subkeys found under App Paths are used primarily for the following purposes:

  • To map an application's executable file name to that 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 shown here:

HKEY_LOCAL_MACHINE
     SOFTWARE
          Microsoft
               Windows
                    CurrentVersion
                         App Paths
                              file.exe
                                   (Default) = The fully-qualified path and file name
                                   Path = A semicolon-separated list of directories
                                   DropTarget = {CLSID}
Note  The file name provided in the (Default) value can be stated with or without its .exe extension. If necessary, the ShellExecute function adds the extension when searching App Paths .

If a subkey of App Paths that matches the file name is found, the Shell performs two actions:

  • The (Default) value can be used as the file's fully-qualified path.
  • The Path value for that key can be appended to the end of that process's PATH environment variable. If this functionality is not required, the Path value can be omitted.

The DropTarget REG_SZ value contains the class identifier (CLSID) of an object (usually a local rather than in-process server) that implements IDropTarget. By default, when the drop target is an executable file and no DropTarget value is provided, the Shell converts the list of dropped files into a command-line parameter and passes it to ShellExecute in the lpParameters parameter. The following potential issues could 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 paths are long, file names later in the list could be lost as the command line is truncated.
  • Some applications do not accept multiple file names in a command line.
  • Some applications that accept multiple file names do not recognize the format in which the Shell provides them. 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; for example, printers. 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 providing 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 (Default), Path, and DropTarget values recognized by the Shell, an application can also add custom values to its App Paths executable file subkey.

Applications are encouraged to use the App Paths subkey to provide an application-specific path instead of adding to the global system path.

Registry Subkeys for File Association Attributes

The Shell checks the following registry subkeys and values in the following order of priority.

PrioritySubkey or Value nameDescription
1User CustomizedThis subkey is used only if the user has customized a file name extension's association to override the default. Typically this is either an application subkey or another ProgID.
2ProgIDThis subkey is specified as the default value of the extension subkey.
3SystemFileAssociationsGuarantees that Shell extensions are installed regardless of the current default ProgID or user customization.
4PerceivedTypeThe SystemFileAssociations key under HKEY_CLASSES_ROOT contains the PerceivedType values.
5Base ClassFor files, this is the HKEY_CLASSES_ROOT\* subkey.
6AllFilesystemObjectsAll files and file folders.

Additional Resources

Related Topics

Tags :


Page view tracker