Chapter 3: Installing Programs
Associating a Program with a File Extension Many programs create, edit, or display files of a specific type. For example, the Notepad program (a text editor that comes with Windows) works with text files that usually have the filename extension .txt (the extension is the part of the filename that follows the last dot in the filename). When you open a file with the extension .txt, Windows knows to run Notepad.
The Windows Registry stores file associations, information about which program you use to edit each type of file. Installation programs usually store this information in the Registry, but you can, too. Chapter 38 describes how to view and edit the Registry with the Registry Editor program, but you can use other tools to change your file associations.
Windows offers three ways to create or change a file association: the Open With dialog box, the Folder Options dialog box, and the Edit File Types dialog box. The third method is rarely used.
Associating Files with Programs when Opening a File In an Explorer window, you can tell Windows which program to use when opening files with a particular extension. Follow these steps:
- In an Explorer window, find a file with the extension that you want to associate with a program.
- Right-click the filename and choose Open With from the menu that appears. (If Open With doesn't appear on the menu, you have to use another method of associating the file type with the program; see the next section.) You see the Open With dialog box shown in Figure 3-3. (If a small submenu of programs appears, select Choose Program to display the Open With dialog box.)
Figure 3-3: Which program do you want run to open this file (and files like it)?
- Select the program to run, or click Browse to find the program file.
- Click the Always Use The Selected Program To Open This Kind Of File check box and click OK.
Windows Explorer permanently saves the association of the filename extension with the program, and it opens the file you selected with the program you specified.
Associating Files with Programs by Using Folder Options Another way to associate a file type (file extension) with a program (or change the program associated with a file type) is to use the File Types tab on the Folder Options dialog box.
Editing an Existing Association To edit a file association, follow these steps:
- Choose Start | Control Panel, click Appearance And Themes, and run Folder Options. You see the Folder Options dialog box. (You can also display this dialog box by choosing Tools | Folder Options from any Explorer window.)
- Click the File Types tab, shown in Figure 3-4.
Figure 3-4: The Folder Options dialog box with the File Types tab selected
- In the Registered File Types list, click the type of file you want to associate with a program. (Scroll down the list--it's long.) When you select a file type, more information about that file type appears in the Details For File Type box. You also see two buttons: Change (to associate one program with the file type) and Advanced (to associate multiple programs with the file type).
- To see or change which program Windows runs to open this type of file, click Change. You see the Open With dialog box (see Figure 3-3). Select the program to run or click the Click Here link (in "If the program is not in the list, click here") to find the program file. Then click OK.
- Close the Open With and Folder Options dialog boxes.
Windows now knows to run the program you specified when you open a file of this type.
Creating a New Association You can create a new file type, with a new extension.
- Choose Start | Control Panel, click Appearance And Themes, run Folder Options, and click the File Types tab (see Figure 3-4).
- If the file extension doesn't appear in the list of Registered Files Types, click New to display the Create New Extension dialog box, shown here:
- Type the extension in the File Extension box.
- If you know the Windows file type (that is, the name of the Windows class or object that this file extension contains), click Advanced to expand the Create New Extension dialog box to include the Associated File Type list. Choose the file type from the (very long) list.
- Click OK. Windows adds the new type at the top of the list (not in alphabetical order, unless you close and reopen the dialog box).
- Select the program to associate with this new extension by following the steps in the previous section.
Editing a File Association Rather than telling Windows that one program can handle a file type, you can specify different programs for different actions. You rarely need to do this: installation programs use this facility when registering a new program to handle file types; human beings almost never need to change the details of file type association.
Displaying the Edit File Types Dialog Box Follow these steps to specify the settings for a file type:
- Choose Start | Control Panel, click Appearance And Themes, run Folder Options, and click the File Types tab (see Figure 3-4).
- Choose a file type from the Registered File Types list.
- Click the Advanced button. You see the Edit File Type dialog box, shown in Figure 3-5. It displays the information that the Registry knows about this file type, including the icon to use for files of this type and a description of the file type. The Actions box lists the tasks that Windows knows how to perform for files of this type: open, print, edit, and other actions. For each action, you can tell Windows which program to use; for example, you can use Internet Explorer to display .gif files, but use Paint Shop Pro to edit and print them.
Figure 3-5: Specifying which programs open and print one file type
- To change which icon appears for this type of file, click the Change Icon button. Windows displays the available icons. Click one and click OK.
- To see the details of what Windows does when you choose a command like Open or Print from a shortcut menu for a type of file, choose the action from the Actions list and click the Edit button. You see the Editing Action For Type dialog box (Figure 3-6). For information about the entries in this dialog box, see the next section. Click OK when you have finished.
Figure 3-6: DDE messages let you control exactly how Windows handles each file type.
- Click any of the three settings that appear on the Edit File Type dialog box, if you want to change their settings:
- Confirm Open After Download Specifies to open files of this type after downloading.
- Always Show Extension Specifies the extension always appears after filenames of this type.
- Browse In Same Window Specifies if the program that opens this program is already running, you want to open the file in the existing program window, rather than opening another window.
- Click OK to store your changes to the way that Windows handles files of this type.
Actions and DDE Messages Associated with File Types In addition to telling Windows which program to run for each file type, you can define as many actions for a file type as you want. For example, you can define one action that opens files of that type and another action that prints files. There are two types of actions:
- Regular actions These actions are listed on the shortcut menu that appears when you right-click filenames in Explorer windows. For example, when you right-click a filename with extension .txt, the Open and Print commands appear on the shortcut menu; the Open and Print actions associated with the .txt file type determine what these commands do.
- DDE actions These actions define how data can be moved from one program to another using DDE (Dynamic Data Exchange, a method for programs to exchange information). DDE actions do not appear on the shortcut menu when you right-click filenames.
Specifying regular actions is useful if you use two programs with files of one file type--for example, you might use your browser to view HTML files, but your Web page editor to create and edit those files. Associate one program with the file type. Add the second program to the actions for that file type. Single- or double-clicking a file of that type runs the first program. To run the second program, right-click the file and choose the program from the shortcut menu. In the Edit File Type dialog box, you choose an action and click Edit to see the Editing Action For Type dialog box (Figure 3-6)). The Application Used To Perform Action box contains the command line Windows executes when you open files of this type. The command line usually consists of the full pathname of a program, possibly followed by a space and %1. The %1 represents the name of the file you want to open; that is, this command runs the program and tells the program to open the file you double-clicked.
If the Use DDE check box is not selected, it is a regular action (that is, a command that appears on the shortcut menu, which appears when you right-click a file of this type). In this case, the dialog box has only two settings:
- Action Specifies the name of the action, which appears in the Edit File Type dialog box and on the shortcut menu you see when you right-click filenames of this type. You don't have to capitalize the first letter of the action: Windows capitalizes the first letter of the action name when it appears on the shortcut menu. You can choose a letter to be underlined on the shortcut menu: precede the letter with an ampersand (&). You can choose a command from the shortcut menu by typing the underlined letter.
- Application Used To Perform Action Specifies the program to run to perform this action on this type of file.
If the Use DDE check box is selected, the action is a DDE action, and you see four additional settings:
- DDE Message Specifies the DDE command for this action.
- Application Specifies the DDE application string to start a DDE link with the program. If this box is blank, Windows runs the program specified in the Application Used To Perform Action box.
- DDE Application Not Running Specifies the DDE command to use if the program (specified in the Application box) is not already running. If this box is blank, Windows sends the same command specified in the DDE Message box.
- Topic Specifies the DDE topic string to start a conversation with the program. The default DDE topic string (used if this box is blank) is "System."