Adding File Templates


Adding File Templates

'm sure you know about the New menu. Right-click within any folder, click New, and choose one of the templates available to create a new, empty file; then double-click the new file to edit it. By default, Windows provides the following templates: Briefcase, Bitmap Image, Wordpad Document, Rich Text Document, Text Document, Wave Sound, and Compressed (Zipped Folder). You can add templates, though, making the chore of starting new files quicker and easier.

Adding new templates is a two-step process:

  1. In the file extension key HKCR\.ext, create the ShellNew subkey.

  2. Add one of the following four values to the ShellNew subkey to define how Windows creates new files of the .ext type:

    • NullFile.

      This is an empty REG_SZ value. Windows creates a zero-length file. Make sure that the associated program can handle empty files.

    • FileName.

      This is a REG_SZ value that contains the name of a template file. By default, Windows looks in %UserProfile%\Templates for this file, but you can include an explicit path.

    • Data.

      This is a REG_BINARY value containing a binary stream of data that Windows uses to create the new file.

    • Command.

      This is a REG_SZ value. Windows executes the command in this value, passing it the path and name of the file it's to create.

For example, the template for the .txt file extension creates a null file. Double-click the file to edit it in Notepad. If you'd rather create the file and open it in Notepad automatically, remove the value NullFile from the key HKCR\.txt\ShellNew. Then add the value Command, and set it to Notepad.exe "%1". When you create a new text file using the New menu, Notepad starts and prompts you to choose whether you want it to create the new file. Ideally, any application you launch using the Command value would have a command-line option to suppress the prompt, but as most don't, you have no choice but to answer it.



Microsoft Windows Registry Guide
Microsoft Windows Registry Guide, Second Edition
ISBN: 0735622183
EAN: 2147483647
Year: 2003
Pages: 186

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