Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windows Shell
Shell Extensibility
Extending Explorers
 File Types

  Switch on low bandwidth view
File Types

[This documentation is preliminary and is subject to change.]

Files with a common file extension (.doc, .html, and so on) are the same type. When developing an application that uses files, you can use existing, well-defined file types. For example, if you create a new text editor, then you would use the existing .txt file type. In other cases, you may need to create a new file type.

This topic is organized as follows:

Public Versus Private File Types

Public file types are also known as popular or contentious because competing applications might want to be associated with these file type.

Some characteristics of public file types include:

  • Applications from multiple vendors are likely to handle them
  • They are typically defined by standards bodies, or promoted by their defining organizations as interchange formats
  • They are often exchanged between computers and users for diverse purposes
  • They need to be supported on many different platforms

Some examples of file types that are considered public are the image formats .png, .gif, .jpeg, and .bmp, and the audio formats .wav, .mp3, and .au.

Unlike public file types, private or proprietary file types typically have a format that is implemented and understood by only one application or vendor. As a result, private file types are typically not prone to conflicts between applications. Some file types may start their life as private file types, but later become public file types.

Note  Microsoft Windows does not differentiate between public and private file types. This separation is only relevant in making decisions about your choice of file type registration.

Choose a File Type Extension

Your file type us identified by the file extension.

To define a new file type:

  1. Choose a long file extension you want to use to identify the file type.

    For more information, see File Type Handlers.

  2. Check the Internet Assigned Numbers Authority (IANA) MIME database to determine if the file extension is already associated with another application.

  3. We recommend that you also define a MIME type when defining a new public file type, and register it with IANA MIME. There is no cost for registration.

    For more information, see the IANA World Wide Web link Web site.

Register a File Type

If you plan to associate the file with an existing application, locate an application ProgID in the registry. To associate the file type with a new application, define a ProgID for your application. For information about defining a new ProgID, see Programmatic Identifiers.

File extension keys have the following general form: extension=ProgID. The registry stores the file extension keys under HKEY_CLASSES_ROOT .

It is important to include the leading period when creating file type key entries in the registry. For example, if you want a file type with the short extension .myp and the long extension .myp-file to open with an application called MyProgram, use the following syntax:

HKEY_CLASSES_ROOT
     .myp
          (Default) = ApplicationVendor.MyProgram
     .myp-file
          (Default) = ApplicationVendor.MyProgram
     ApplicationnVendor.MyProgram
          (Default) = MyProgram Application

As demonstrated in this example, if you also register a short file extension you should create a key for the short extension as well. For more information, see File Type Handlers.

Set Optional Keys and File Type Extension Attributes

File type extension entries in the registry have several optional sub keys and attributes.

The file type extension entries that are used by file associations are listed as follows:

ValueAction
Default Value

Set the default value of the extension key to the ProgID to which it is linked. This is a registry string (REG_SZ).

PerceivedType

Set this string to the PerceivedType to which the file belongs, if any. This string is not used by Windows versions prior to Windows XP.

For more information, see PerceivedTypes, SystemFileAssociations, and Application Registration.

Content Type

Set this string to the file type's MIME content type.

OpenWithProgids

This subkey contains a list of alternate ProgIDs for this file type. The programs for these ProgIDs appear in the Open With dialog box. Whenever a program takes over this file type by changing the default value, it should also add an entry to this list.

OpenWithList

This subkey contains one or more application keys for applications to appear in the Open With dialog box entry for the file type.

 

The general form of a file extension key is as follows:

HKEY_CLASSES_ROOT
     .ext
          (Default) = ProgID.ext.1 (REG_SZ)
          PerceivedType = PerceivedType (REG_SZ)
          Content Type = mime content type (REG_SZ)
          OpenWithProgids
               ProgID2.ext.1
               ProgID3.ext.1
          OpenWithList
               AlternateProgram1.exe
               AlternateProgram2.exe
          ProgID.ext.1
               shellnew

Important considerations regarding file types include:

  • The HKEY_CLASSES_ROOT registry key is a view formed by merging HKEY_CURRENT_USER\Software\Classes and HKEY_LOCAL_MACHINE\Software\Classes . In general, HKEY_CLASSES_ROOT is intended to be read from but not written to. For more information, see HKEY_CLASSES_ROOT Key.
  • To register a file type globally on a particular computer, create an entry for the file type in HKEY_LOCAL_MACHINE\Software\Classes .
  • To make a file type registration visible to the current user only, create a file type entry in HKEY_CURRENT_USER\Software\Classes .
  • To ensure that an application is included in the Open With dialog box for a file type, include a reference to the application in either the OpenWithProgids or OpenWithList key for the file type.
  • Any time you create or change a file association, it is important to notify the system that you have made a change by calling SHChangeNotify, and specifying the SHCNE_ASSOCCHANGED event. If you do not call SHChangeNotify, then the change may not be recognized until after the system is rebooted.
  • To retrieve information regarding a file association from the registry, use the IQueryAssociations interface.

For a sample scenario of this procedure, see File Association Sample Scenario.

Define File Type Attributes

Assigning file type attributes to an associated ProgID enables you to control some aspects of the file type's behavior. Prior to Windows Vista, these attributes could enable you to limit the extent to which the user can use the Folder Options property tab to modify various aspects of the file type, such as its icon or verbs.

File type attributes are binary flags specified as REG_DWORD values in the file type's associated ProgID key. To assign attributes for a file class, add an EditFlags REG_DWORD value to the file type's associated ProgID key and set it to the desired attribute value. The flags may be combined with a logical OR to form a single attribute value.

For a list of file class attributes and their hexadecimal values, see FILETYPEATTRIBUTEFLAGS.

The following example assigns the FTA_NoRemove (0x00000010) and FTA_NoNewVerb (0x00000020) attributes to the .myp file class.

HKEY_CLASSES_ROOT
     .myp-file
          (Default) = ApplicationVendor.MyProgram
     ...
     ApplicationVendor.MyProgram
          (Default) = MyProgram Application
          EditFlags = 0x00000030

Exclude an Application from the Open With Dialog Box for Unassociated File Types

In Windows 7 and later, when a user attempts to open a file that is not a member of any registered file type (that is, an unknown file type), or when a user selects Open With... or Open With -> Choose Default Program... from a file's shortcut menu, the Shell presents the shortcut menu, which enables the user to specify the program is used to open the file.

Prior to Windows 7, when a user attempts to open a file that is not a member of any registered file type, or when a user selects Open With... or Open With -> Choose Program... from a file's shortcut menu, the Shell presents the Open With dialog box, which enables the user to specify the program is used to open the file.

The following diagrams illustrate examples of the Open With dialog box.

Open With dialog box on Windows XP

Open With dialog box on Windows Vista

Applications that are listed in the Open With dialog box are registered as subkeys of HKEY_CLASSES_ROOT\Applications . By default, an application with a key in HKEY_CLASSES_ROOT\Applications is listed in the Open With dialog box for any file the user attempts to open, including file types which the application is not registered to handle.

Sometimes an application should not be used to open files types it is not registered to handle. To exclude an application from the Open With dialog box for files that the application is not registered to handle, add an empty REG_SZ value named NoOpenWith to the application's key.

For example, assume that MyProgram.exe is registered to handle .myp and .txt files. The following sample registry entry excludes MyProgram.exe from being listed in the Open With dialog box for any file type other than .myp or .txt.

HKEY_CLASSES_ROOT
     Applications
          MyProgram.exe
               NoOpenWith

Additional Resources

Related Topics

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
docs missing for keys under HKCR\Applications\<AppName.exe>      Chris_Guzak   |   Edit   |   Show History
HKCR\Applications\<AppName.exe>\SupportedTypes
".ext1"=""
".ext2"=""

lets an application provide an include list of file types that it supports; this avoids the app being added to the open with menu for a file type that it can not open. this is useful if an application can save a particular file type but not open it. in addition use FOS_DONTADDTORECENT when calling the file save dialog to avoid the file type being added to the list of types that the application can support via OpenWith.

HKCR\Applications\<AppName.exe>\shell\<verb name>

lets an applicaiton provide the verb implementation for the verb listed. this can include the cmd line method (shell\<verb>\command=<command line>, the DropTarget method, or others.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker