File Extension Keys

Files containing particular types of data usually have the same file extension. For example, Microsoft Word 2002 documents have the .doc file extension. Although three-character extensions are the norm, extensions can be longer. Files with the same extension are members of a file class. File classes define behaviors common to all files that share that file name extension. By customizing file associations, you can specify which application opens a file, add commands to the shortcut menu, or even specify a custom icon that Windows Explorer will use for that type of file.

File associations have two parts. The first is a file extension key, HKCR\.ext. When Windows XP needs information about a file type, it looks up this key. The default value of the file extension key contains the name of the program class associated with it, which is the second part. Program classes are in HKCR\progid, where progid is the program ID of the application. The default value of progid contains the friendly name of the application. For example, the file extension key HKCR\.txt has a default value of txtfile. Look in HKCR\txtfile to find the program class associated with it, and you'll find the description Text File. Figure A-1 illustrates this relationship with the .ani file extension.

click to expand
Figure A-1: The default values of file extension keys associate these keys with program classes.

File extension keys can have a variety of subkeys and values. The following list describes the most common:

  • PerceivedType. This REG_SZ value indicates the file's perceived type. Windows XP is the only version of Windows that uses this key. See "

  • Content Type. This REG_SZ value indicates the MIME type.

  • OpenWithProgids. This subkey contains a list of alternate program classes associated with the file extension. Windows XP displays these programs in the Other Programs area in the Open With dialog box.

  • OpenWithList. This subkey contains one or more keys bearing the names of the applications to appear in the Recommended Programs area in the Open With dialog box. See "

  • ShellNew. This subkey defines a template from which Windows XP creates a new file when users choose this file type on the New menu. See "

OpenWithList

Sometimes users want to open files with applications that aren't associated with the file class. For example, a user might want to open a document in WordPad instead of Microsoft Word 2002. In other cases, users might want to open files that have no file associations. The Open With dialog box allows both scenarios.

The applications you see in the Open With dialog box are registered in HKCR\Applications. This key contains one subkey for each application, and the subkey bears the name of the program's executable file. You can prevent Windows XP from displaying an application in the Open With dialog box by adding the REG_SZ value NoOpenWith to HKCR\Applications \ program .exe.

PerceivedType

Perceived types are similar to file types, except perceived types refer to broad categories of file format types, rather than to specific types of files. Think of them as super types. Perceived types include images, text files, audio files, and compressed files. In Windows XP, you can associate a perceived type with each file type. For example, the file extensions .bmp, .png, .jpg, and .gif are perceived as image files. Windows XP defines several perceived file types. In the file extension key, you set the REG_SZ value PerceivedType to one of the following:

  • Image

  • Text

  • Audio

  • Video

  • Compressed

  • System

ShellNew

When users right-click in a folder and click New, they see a list of template files that they can create in the folder. You can extend the New menu with additional file templates. First make sure that HKCR contains a file extension key for the type of file you're creating. Then create the ShellNew subkey under the file extension key. For example, to define a template for files with the .inf extension, create the key HKCR\.inf\ShellNew. Then in ShellNew, create one of the following values:

  • Command. Executes an application. This is a REG_SZ value command to execute. For example, you use a command to launch a wizard.

  • Data. Creates a file containing specified data. This is a REG_BINARY value that contains the file's data. Windows XP ignores this value if either NullFileor FileName exists.

  • FileName. Creates a file that is a copy of a specified file. This is a REG_SZ value that contains the path and name of the file to copy. If the file is in the user profile's Templates folder, you can leave off the path.

  • NullFile. Creates an empty file. This is a REG_SZ value that contains no data. If the value NullFile exists, Windows XP ignores Data and FileName.



Microsoft Windows XP Registry Guide
Microsoft Windows XP Registry Guide (Bpg-Other)
ISBN: 0735617880
EAN: 2147483647
Year: 2005
Pages: 185

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net