Program Class Keys

Program classes define a program and the behaviors associated with it. Program classes are in HKCR\progid, where progid is a program identifier. For example, HKCR\txtfile is a program class. Windows XP associates file extension keys with program classes through the file extension keys' default values. The default value of the program class contains the class's friendly name. The proper format of a program ID is application.component.version. For example, Word.Document.6 is a proper program ID. This format isn't always used, though, not even by Windows XP.

Program classes contain the following values and subkeys:

  • AlwaysShowExt. This empty REG_SZ value indicates that Windows Explorer should always show the file extension, even if the user has hidden it.

  • CurVer. The default value of this subkey contains the program ID of the most current version.

  • DefaultIcon. The default value of this subkey is the default icon that Windows XP displays for files associated with this program class. This value can be either a REG_SZ or a REG_EXPAND_SZ string, but it must use the format file,index, where file is the path and name of the file containing the icon, and index is the index of the icon in the file. Optionally, if you know the exact resource ID, you can use the format file,-resource. See "

  • FriendlyTypeName. This REG_SZ value is the friendly name for the program class. You see this value in Windows Explorer. In Windows XP, this value supercedes the program class's default value, which earlier versions of Windows still use and Windows XP maintains for backwards compatibility. Still, the default value of the program class and this value should remain the same for consistency. Windows XP commonly specifies a resource instead of a string in this value. The format is @file,index or @file,-resource.

  • EditFlags. This is a REG_DWORD value that controls how Windows XP handles file classes linked to this program class. You can also use the EditFlags value to control users' ability to modify certain aspects of these file classes. See "

  • InfoTip. This REG_SZ value contains a brief message that Windows XP displays for this program class when users position the mouse pointer at a file or folder linked to it. This value can be a string or a resource as described for the FriendlyTypeName value.

  • IsShortcut. This empty REG_SZ values indicates that the file is a shortcut. Windows Explorer displays the shortcut overlay on top of the file's icon.

  • NeverShowExt. This empty REG_SZ value indicates that Windows Explorer should never show the file extension, even if the user has configured Windows Explorer to show file extensions for known types.

  • Shell. This subkey contains commands (called verbs) defined for the program class. For example, the txtfile program class defines the commands for opening and printing text files. See "Shell," later in this appendix, for more information. This is the heart of most customizations you'll do in HKCR.

start sidebar
Special Program Classes

The program classes Directory, Drive, and Folderare specialized program classes that are useful to customize. The organization of these program classes is just like any other. They contain Shell subkeys that you can customize to add, change, and remove the commands you see on their shortcut menus. The trick is knowing which program classes apply to which types of objects:

  • Directory. This program class applies to any normal folder that you can view in Windows Explorer.

  • Drive. This program class applies only to drives that you see in My Computer.

  • Folder. This program class applies to all system folders, drives, and other folders that you can view in Windows Explorer.

The program class Folder is the most inclusive. It includes all folders and all special system folders, such as Control Panel, My Computer, and so on. As such, this is typically the program class that you want to customize unless you need to restrict your customization to specifically drives or non-system folders.

end sidebar

DefaultIcon

Windows XP provides default icons for every type of object you see in Windows Explorer. That includes files, drives, and so on. You can customize these icons as described in Chapter 4, "Hacking the Registry." Each file class's DefaultIcon value contains the path and name of the file containing the icon. You can assign an icon file, which has the .ico extension to this value, or you can assign an icon from program files using the formats file, index or file,- resource. Index is an incremental index number of a resource, and resource is a specific resource ID. Doing this requires that you know either the relative location of an icon in a file or the icon's exact resource ID. To find this value, you can use a third-party resource editor, many of which are shareware tools you can download from your favorite shareware Web site.

EditFlags

The REG_DWORD value EditFlags gives you some control of a program class's behavior. You can also use it to limit the ways in which users can change a program class. Each bit in this value represents a different setting, and Table A-1 describes the bit mask of each. See Chapter 1, "Learning the Basics," to refresh your memory on how to use bit masks.

Table A-1: Bits in EditFlags

Bit mask

Description

0x00000001

Excludes the file class.

0x00000002

Shows file classes, such as folders, that aren't associated with a file extension.

0x00000004

Denotes that the file class has a file extension.

0x00000008

Prevents users from editing the registry entries associated with this file class. They can't add new entries or change existing entries.

0x00000010

Prevents users from deleting the registry entries associated with this file class.

0x00000020

Prevents users from adding new verbs to the file class.

0x00000040

Prevents users from changing verbs.

0x00000080

Prevents users from deleting verbs.

0x00000100

Prevents users from changing the description of the file class.

0x00000200

Prevents users from changing the icon assigned to the file class.

0x00000400

Prevents users from changing the default verb.

0x00000800

Prevents users from changing the commands associated with verbs.

0x00001000

Prevents users from modifying or deleting verbs.

0x00002000

Prevents users from changing or deleting DDE-related values.

0x00008000

Prevents users from changing the content type associate with this file class.

0x00010000

Allows users to safely use the file class's open verb for downloaded files.

0x00020000

Disables the Never Ask Me check box.

0x00040000

Denotes that the file class's file name extension is always shown, even if the user hides known file extensions in the Folder Options dialog box.

0x00100000

Denotes that members of this file class are not added to the Recent Documents folder.

Shell

File classes contain verbs, which are commands that Windows XP executes to complete certain actions. Verbs are related to the shortcut menus that you see when you right-click a file. Each item on the shortcut menu is a verb. A program class's verbs are in HKCR\progid\Shell, which contains one subkey for each verb. For example, HKCR\txtfile\Shell contains the subkeys openand print, which are the Open and Print verbs. The default value of the Shell key indicates the name of the default verb. For example, if the default value of Shellis edit, this indicates that the subkey edit is the default verb. If the default value of Shellis empty, Windows XP uses the verb open. If that verb is missing, it uses the first verb as the default. Figure A-2 shows an example that relates the Shell key to shortcut menus.


Figure A-2: This figure shows the relationship of a program class's verbs to the shortcut menu.

Canonical verbs are built in to the operating system. Examples of canonical verbs are Open, Edit, and Print. One thing that makes canonical verbs special is that Windows XP automatically translates them to different languages as necessary. The following list shows typical canonical verbs, some of which are special verbs that users don't see on menus:

  • Edit. This is usually the same as Open, but enables the user to edit the file's contents.

  • Explore. This opens the selected folder in Windows Explorer.

  • Find. This opens Search Assistant with the selected folder as the default search location.

  • Open. This is typically the default verb, which opens a file in the associated application.

  • Open As. This opens the Open With dialog box.

  • Play. This indicates that the contents of the file will be opened and played, rather than just opening the file and waiting for the user to play it.

  • Print. This causes the application to print the file's contents and exit. Applications should display as little user interface as possible.

  • PrintTo. This is a special verb that supports drag-and-drop to printers. Users don't see this verb on shortcut menus.

  • Preview. This enables users to preview files without opening or editing them. An example is previewing images, rather than opening to edit them.

  • Properties. This opens the Name Properties dialog box.

  • RunAs. This is a special verb that enables users to open a file or run an application in the context of a different user. They can see this verb on shortcut menus by holding down the Shift key while right-clicking the file.

You can add supplemental verbs to any program class. For example, you can add the verb Edit in WordPad to the txtfileprogram class to have the option of editing text files in WordPad without changing the default verbs. To add verbs to a program class, create a new subkey for it in the Shell key. The new subkey is HKCR\progid \Shell\ verb. Then set the default value of verb to the text you want to see on the shortcut menu. You can make any character in the description a hotkey by prefixing it with an ampersand (&). For example, Open in &WordPad makes the letter W a hotkey for that verb. Add the subkey command to verb, and set its default value to the command you want to execute when you choose that verb. Figure A-3 shows an example.

click to expand
Figure A-3: Add supplemental verbs to a program class by creating new subkeys in Shell.

The default value of command needs a bit more explanation. First if the path and name of the program file contain spaces, you should enclose the command in quotation marks. Second you use %1 as a placeholder for the file name that you right-clicked. For example, assume the command is Notepad "%1". If you right-click C:\Sample\Text.txt, the command is Notepad "C:\Sample\Text.txt." Note that you should always enclose %1in quotation marks so that the command works with long file names.

You see extended verbs only when you press the Shift key while right-clicking a file. Creating extended verbs is a handy way to remove clutter from shortcut menus. For example, you can add extended verbs that you don't use often to shortcut menus, hiding them behind the Shift key. To make a verb an extended verb, add the empty REG_SZvalue extendedto the verb's subkey, Shell\ verb.



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