February 5, 1996
Associate unknown file types and gain right mouse control
In the past three weeks, I've described new ways to use your right mouse
button under Windows 95. The first two columns explained tricks involving
the Send To command you see on the pop-up menu (called the context menu) that
appears when you right-click a file in the Explorer. Last week, the subject
was how to add whole new actions to the context menu for specific file types,
such as .TXT or .DOC files. (If you missed those columns, see Reader
resources, page 88, to order back issues.)
In the final column of this series, I'd like to show you the most powerful
secret of all. It's an undocumented way to define new context menu actions
that take effect not just for a single file type but for all file types.
Even better, you can define actions that show up only when a file you
right-click isn't associated with any application at all -- a so-called
Unknown file type.
This latter action is most useful when you encounter, for example, files
named README.1ST, MANUAL.BIN, or OUTPUT.LOG. Would you normally try to
inspect these files by opening them in Notepad? That won't work if the files
are anything other than plain text files less than 50KB in size.
It would be much better to be able to open such files in your favorite
hexadecimal editor, which is capable of reading any file, regardless of the
format or lack of one. In fact, you may want to have your hexadecimal editor
appear in your context menus for all file types you might right-click. But
Win95 provides no easy way to add a context menu action for all file types,
unless you figure that defining an action manually for 50 or 60 file types is
easy.
Here's how to add both the Unknown file type and the All file type to the
list of file types you can associate with applications:
Step (1) Use Notepad or any text editor to create a text file called
ALLTYPES.REG, containing the following five lines:
REGEDIT4
[HKEY_CLASSES_ROOT\Unknown]
"EditFlags"=hex:02,00,00,00
[HKEY_CLASSES_ROOT\*]
"EditFlags"=hex:02,00,00,00<$E""><$V10>
Step (2) Save ALLTYPES.REG in any folder you like or on the Desktop. Exit
your text editor. Find ALLTYPES.REG on your Desktop or in the Explorer and
right-click it. On the context menu that appears, click Merge.
That's it. You've just added four lines to your Registry. The next time you
click View, Options, File Types in the Explorer, there will be two new file
types with which you can associate actions. The one at the top of the list
will be file type "*". The other, farther down the list, will be file type
Unknown.
You can associate WordPad with all Unknown file types. WordPad can open
files of almost any format except executables, unlike Notepad, which chokes
on nontext files. If you have a hexadecimal editor, use that in the above
example instead.
In the Explorer, click View, Options, File Types. Select Unknown in the
scrolling Registered File Types list. Click the Edit button, then the New
button. In the Action box, type Open in WordPad. In the Application box,
type "C:\Program Files\Accessories\Wordpad.exe". (The quotes are necessary
because there is a space in the Program Files folder name.) Close all the
dialog boxes. Now right-click any unassociated file type, and you should see
a new Open in WordPad option on the context menu.
This technique offers you unlimited control over the powers of your right
mouse button.
Brian Livingston is the coauthor of the new Windows 95 Secrets and author of three other Windows books (IDG Books). Send tips to brian_livingston@infoworld.com or fax: (206) 282-1248.
Missed a column? Go back for more.
Copyright © 1996 by InfoWorld Publishing Company