Click here to Skip to main content
14,880,917 members
Articles / Programming Languages / C++
Posted 13 Apr 2007


105 bookmarked

Common Registry Settings

Rate me:
Please Sign up or sign in to vote.
4.87/5 (41 votes)
13 Jul 2007CPOL6 min read
Essential registry tips for programming, including registering your application with Windows and creating custom file types


The Registry is a powerful part of the Windows operating system and is most valuable to programmers. For instance, you could have your application show up in Windows' Add/Remove Software or create your own file types. That is all done via the Registry and this article will show you how.

Registering your application

Let's start with the basics registering your application with Windows. By doing this, you can add your application to Windows' Add/Remove Software. There are two different keys for this, depending on how you want to register your application. That is, whether you want to register it for the current user only or for anyone who uses the computer (global).

For the current user: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall

For global users: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall

Now first you will create a sub key with the name of your program, i.e. "ExampleApp," and then add any of the following values:

PropertyDescriptionReg Type
AuthorizedCDFPrefixThe update URL for the applicationREG_SZ
CommentsAdditional comments to be displayedREG_SZ
DisplayIconThe display icon of the installed program, usually automatically taken from install pathREG_SZ
DisplayNameThe display name of the installed programREG_SZ
DisplayVersionThe version of the installed program (displayed)REG_SZ
EstimatedSizeEstimated size of the entire programREG_SZ
HelpLinkURL for product supportREG_SZ
HelpTelephonePhone number for product supportREG_SZ
InstallDateInstallation dateREG_SZ
InstallLocationLocation of the installed programREG_SZ
InstallSourceLocation of source filesREG_SZ
LanguageLanguage of the programREG_SZ
ModifyPathThe path to a program's modification/repair fileREG_SZ
NoModifyTells Windows not to display a "Modify" option for the program. (0=true, 1=false)REG_DWORD
NoRepairTells Windows not to display a "Repair" option for the program. (0=true, 1=false)REG_DWORD
PublisherPublisher nameREG_SZ
ReadmeThe path to a README fileREG_SZ
UninstallStringThe path to a program's Uninstall fileREG_SZ
URLInfoAboutThe URL to the application/publisher's pageREG_SZ
URLUpdateInfoThe URL used to update information about the applicationREG_SZ
VersionThe version of the installed program (not displayed)REG_SZ
VersionMajorThe major version of the installed program (not displayed)REG_SZ
VersionMinorThe minor version of the installed program (not displayed)REG_SZ

There are many options available, but most programs only use the DisplayName, DisplayVersion, NoModify, NoRepair and UninstallString properties. Very rarely have I ever seen a program with more. In the end, you should have something similar to the image below, although you may decide to specify more properties.

Screenshot - RegUninstall.png


Next is how to launch your program automatically during start-up. As previously, you can specify your application's start-up for either the current user, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, or for all users, HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run. This time, you will only have to specify one key named after your application. The value should be a string value of the path to your application, like so:

Screenshot - RegStart.png

Open with

One of the biggest needs of a programmer is to allow the user to open a file in their program. For this process, there are two main steps:

Step 1

Specify your application by defining a sub key in the HKEY_CLASSES_ROOT\Applications key. Now you will name your key the same as your application file with the EXE extension, i.e. Example.exe. From here, you will create another sub key: \shell\open\command. You will then specify your application's path in the (Default) value, followed by any necessary parameters. You must also follow a standard: the path name and parameters must be together in double quotes followed by the "%1" verb. Windows substitutes this verb with the file path of the file you are opening. The "%1" verb must also be in double quotes and must be before any other parameters.

Screenshot - RegOpen.png

Step 2

Next, you must find the file extension you want your program to be associated with. Extensions are located in the HKEY_CLASSES_ROOT key. For this example, I will use a TXT extension. Then create the sub key \OpenWithList under the file extension key and name your sub key the same name as your application file from the previous step.

Screenshot - RegFileType.png

The application file keys in the above two steps must match exactly. Otherwise, Windows will not be able to open the file correctly.

File association

File association is similar to the "Open with" procedure. This time, however, you will create a sub key in the HKEY_CLASSES_ROOT key with the same sub keys as the first step in the "Open with" procedure. It doesn't really matter what you name this descriptive key, but it's usually a description of the file type. For example, the TXT extension has an associated key named "txtfile." The only difference between this and the "Open with" procedure is that you will have an additional sub key named DefaultIcon. Inside, you will specify the path of the icon you want the associated file, such as a text file, to have in the (Default) value. You will then add your descriptive key to the (Default) value of the file extension you want in the HKEY_CLASSES_ROOT key, as created in the second part of the "Open with" procedure.

Screenshot - RegFile.png

Shell menus

Finally, we come to the shell menus, which are similar to both the "File association" and "Open with" procedures. This time, we will use two keys depending on how you want your shell menu to be set up. Let's say you want to add a menu option called "Test" to a TXT file. You would go to HKEY_CLASSES_ROOT\txtfile\shell. This key, as you have seen before, will contain a sub key named "open." You will basically follow the same steps as before: creating your menu option -- i.e. a sub key named "test" -- and another sub key in that named "command." In "test," you will add the command that you would like to appear in the Context Menu in the (Default) value. In "command," you will add your application's path and the "%1" verb to the (Default) value.

Screenshot - RegShellMenu.png

Now if you want to add a menu item to any file associated with your program, you must repeat the above steps for your application's key, i.e. HKEY_CLASSES_ROOT\Applications\Example.exe. If you want to add a menu option to a directory or drive, remember that there are always the drive and folder keys in HKEY_CLASSES_ROOT, which involve the same steps as above.


The Registry can get confusing at times, but hopefully I have helped clarify it a bit. Just remember to keep a backup of your Registry settings and always be careful when editing keys. I am always open to more ideas and will be glad to add them to my article.


  • April 13, 2007 - Original version posted
  • May 16, 2007 - Added the "Shell menus" section
  • July 13, 2007 - Article edited and moved to the main article base


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
United States United States
No Biography provided

Comments and Discussions

GeneralMy vote of 5 Pin
David Nash5-Feb-11 16:31
MemberDavid Nash5-Feb-11 16:31 
GeneralThanks Pin
Chuck141128-Sep-10 7:10
MemberChuck141128-Sep-10 7:10 
GeneralVery nice!! Pin
Kenny McKee16-Dec-08 13:46
MemberKenny McKee16-Dec-08 13:46 
GeneralAuthorization Pin
paulnyc13-Aug-07 10:54
Memberpaulnyc13-Aug-07 10:54 
GeneralRe: Authorization Pin
MatrixCoder17-Aug-07 13:27
MemberMatrixCoder17-Aug-07 13:27 
GeneralRe: Authorization Pin
paulnyc18-Aug-07 0:44
Memberpaulnyc18-Aug-07 0:44 
GeneralRe: Authorization Pin
MatrixCoder20-Aug-07 12:00
MemberMatrixCoder20-Aug-07 12:00 
GeneralRe: Authorization Pin
paulnyc26-Aug-07 11:02
Memberpaulnyc26-Aug-07 11:02 
General%1 vs %L Pin
antidemon7-Jun-07 2:22
Memberantidemon7-Jun-07 2:22 
GeneralRe: %1 vs %L Pin
MatrixCoder7-Jun-07 10:18
MemberMatrixCoder7-Jun-07 10:18 
Generalgood work Pin
pino.lassandro22-May-07 5:43
Memberpino.lassandro22-May-07 5:43 
GeneralRe: good work Pin
MatrixCoder22-May-07 8:06
MemberMatrixCoder22-May-07 8:06 
GeneralVery useful! Pin
ADLER113-Apr-07 10:44
MemberADLER113-Apr-07 10:44 
GeneralI'll second that! Pin
wtwhite19-Apr-07 19:04
Memberwtwhite19-Apr-07 19:04 
GeneralVery handy! Pin
Hans Dietrich13-Apr-07 8:34
mentorHans Dietrich13-Apr-07 8:34 
GeneralRe: Very handy! Pin
MatrixCoder14-Apr-07 8:42
MemberMatrixCoder14-Apr-07 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.