workstation

User Interface
REG Files

    While you can't really stop an application from changing your preferred associations, you can make a text file with the REG extension containing your associations to "undo" any new unwanted associations. Then if you notice a problem, you just double-click your REG file to get your associations back where you like them.

    There are 3 elements to a REG file: the first line, which identifies the file as a REG file, must read "REGEDIT4". Then there's a bracketed "heading" delimiting each registry subkey (no particular order is necessary), and finally any data values for that subkey go directly underneath. So here's an example REG file:

      REGEDIT4

      [HKEY_CLASSES_ROOT\MyApplication\shell\Open\command]
      @="C:\\Program Files\\MyApp\\Path\\EXAMPLE.EXE\"
      "Login Name"=""
      "Password"=""

      [HKEY_LOCAL_MACHINE\Software\Classes\CorelPhotoPaint.Image.7\shell\Open\command]
      @="\"C:\\Program Files\\Corel\\Draw70\\PROGRAMS\\PHOTOPNT.EXE\" -DDE"

    There are two subkeys defined here, each with a full "path" in the registry. In the first subkey, I'm adding a default value @, which will appear in the data pane as No Name, and setting it equal to the shown file path. Notice that the file path has extra backslashes \ in it. In REG files, the backslash is the escape character: you have to use it before double quotes and backslashes if those characters appear in the data value (as they often do in file paths).

    Note that all value names are quoted (except the "@", which produces "No Name" in the Registry data pane).

    Example

    As an example of this technique, here is "jpg.reg", which when double-clicked from Explorer will change the file type associated with JPG to Corel Photo Paint (which already exists in my Registry). Recall that to associate an extention with an application, you have to use the name of the application's registered file type as it appears in its own subkey at the bottom of HKEY_CLASSES_ROOT:

      REGEDIT4

      [HKEY_CLASSES_ROOT\.jpg]
      @="CorelPhotoPaint.Image.7"

    Of course, you could have one REG file with all your preferrred extensions in it, or one with all your preferred Graphics File Formats extensions (like JPG, GIF, PNG, etc).