Double clicking a .doc file will usually start Microsoft Office. Double clicking a .pdf file will usually start Adobe Acrobat Reader. By assigning a default program to a file extension you create a file type association. Any program, even programs you wrote, can be assigned as the default program for any file extension. Creating a file type association for your program is one more important software deployment step that makes your program easier for others to use.

How Do File Type Associations Work?

File type associations associate types of data files with programs. The computer operating system recognizes a data file type by its extension, such as “.doc”, “.pdf”, or “.jpg”. Only one program may be associated as the default program for a particular file type at any time.  The install wizard of a program may automatically register a data file type with its own program.  A user may at any time manually change system settings so a data file type is assigned to a different default program. Therefore, the program associated with each data file type may be different on every computer.

In order for a program to work with the associated file type, the program must be coded to accept the name of a file as an input parameter. The program must then be able to read that data file, process the data in that file, and run successfully using the data that was in that input file. If the program requires data from more than one file, it must be able to locate the additional required files on its own, possibly based on the data that was in the first data file. The only input that will come into a program when a data file is double clicked is the name of the clicked file.

Manually Set a File Type Association

When you double click a file with an extension that is not yet associated with a program, Windows will prompt you to choose a program for opening that type of file.  This creates a file type association for files with that extension.

When you double click a file with an extension that is already associated with a different program, you will not get the opportunity to choose another program. If you want to manually change the program associated with a particular file extension, you must go through the Windows Control Panel options to assign a different program to that file type.

Automatically Set a File Type Association

Many programs set their file type association as part of their install process. This is preferred to expecting the user of the program to set up the file type association manually.

Another of my favorite free programs is Inno Setup.  I use it to create the install wizards for my programs. Inno Setup can be downloaded from One of the many things you can configure for your install wizard using Inno Setup is automatic configuration of a customized file type association.

File Type Name and Icon

When you configure a file type association in Inno Setup, you can also indicate the file type name and file type icon. In other words, when your program is installed and the file type associations are automatically created, any file with that extension listed in Windows Explorer or on the computer desktop will be displayed using the icon and type name you assigned to that file type. This gives your program a much more polished look.

Scope of a File Type Association

File type associations may be set for either all users of the computer or only the current user. When you set the file type association manually as described above, it sets the file type association for the current user only. When you set a file type association automatically during the install of the program, you probably want it set for all users of the computer. However, current user associations take priority over all users of the computer. Current User associations will not be reset to match the new setting for all users.

This became a problem for me when I was working on one of my test programs.  I gave my data file for my Hello World program an extension of .hwd.  Before I set up my file type associations, I unwittingly manually assigned Notepad to open .hwd files.  Unfortunately, when I eventually set up a file type association for .hwd files to default to my Hello World program for all users of my computer, .hwd files still defaulted to open with Notepad for me.  The current user .hwd file type association to Notepad was an unwanted association that I needed to delete.

Windows XP had an option to delete any unwanted file type associations. There is no such option with Windows Vista and Windows 7.  To get around this problem, I recommend another of my favorite free programs that I found, Unassoc.exe. It may be used to remove any unwanted file type associations in Windows Vista and Windows 7. You can download Unassoc.exe from

Can You Claim Any File Extension as Your Own?

Actually, you can. There is no global database where you need to register your use of a file extension for your program. There is nothing that will prevent you from associating your program with an already used file extension. However, it is to your advantage to try to come up with a file extension that no one else (or at least, not many others) are using. Otherwise, there may be data files out there for other programs that would not work with your program.


Creating file type associations is one more deployment step that makes your program easier for others to use.  Write your program so it accepts the name of a data file as input.  Then set up a file type association as part of the installation of your program.

Related posts:

  1. Should You Create a Windows .EXE Wrapper for Java Programs?
  2. Create a Readme.txt File
  3. Create a Software License Agreement
  4. Create Your Own Icons
  5. Is Symantec’s File Insight (SONAR) Deleting Your Programs?

About the Author

Comments are closed.

More Do-It-Yourself Java Games

More Do-It-Yourself Java Games: An Introduction to Java Graphics and Event-Driven Programming is the second book of the Do-It-Yourself Java Games series. You'll learn to create windows and dialogs, to add buttons and input fields, to use images and drawings, and to respond to keyboard input and mouse clicks and drags. You'll create 10 more games including several puzzles, a dice game, a word game, and a card game.

This book assumes you either have an understanding of basic Java programming or you have read the first book, Do-It-Yourself Java Games: An Introduction to Java Computer Programming. Read more.

Do-It-Yourself Java Games

Do-It-Yourself Java Games: An Introduction to Java Computer Programming uses a unique "discovery learning" approach to teach computer programming: learn Java programming techniques more by doing Java programming than by reading about them.

Through extensive use of fill-in blanks, with easy one-click access to answers, you will be guided to write complete programs yourself, starting with the first lesson. You'll create puzzle and game programs like Choose An Adventure, Secret Code, Hangman, Crazy Eights, and many more, and discover how, when, and why Java programs are written the way they are. Read more

Step-by-Step Tutorial

Many of the tips, techniques, and tools discussed in this blog are demonstrated in a detailed step-by-step tutorial in the book, This Little Program Went to Market, by Annette Godtland.

The book takes a computer program through the entire process of creating, deploying and distributing a program, then selling and marketing it (or any other product) on the Internet. Read more.