Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add my own custom file extension into the win 7 registry. And I also want to add a right click option "Play with xPlayer" for this extension.

I want to use it in my C# application. How can I do it using the registry?

share|improve this question

migrated from Feb 9 '11 at 1:08

This question came from our site for professional and enthusiast programmers.

The question is offtopic here and belongs to . The easiest way is to run regedit, check HKEY_CLASSES key for say ".mp3" subkey and see how it works. – Eugene Mayevski 'EldoS Corp Feb 8 '11 at 22:33
Sorry I forgot to say I want to use it in my C# application. And actually I have been doing exactly what you said for some hours now. But I can see here different type of pattern. So I need to know the standard way to do this. – Barun Feb 8 '11 at 22:37

MSDN has extensive documentation on how to work with file extensions in the Registry. Start with these articles:

File Types and File Associations

Guidelines for File Associations and Default Programs

Update: You would need to create the following Registry keys and values at a bare minimum (file extension registrations support a LOT of features):

(Default) = "MyAppExt"

(Default) = "Play with xPlayer"

(Default) = ""c:\path to\xplayer.exe" "%1""

Substitute HKEY_LOCAL_MACHINE if you want your file extension to be accessible to all users on the PC, instead of just the user that is running your app/installer.

For example:

using System;
using Microsoft.Win32;

// substitute "HKEY_LOCAL_MACHINE" if needed...
Registry.SetValue("HKEY_CURRENT_USER\\Software\\Classes\\.xpl", "", "xPlayer", RegistryValueKind.String);
Registry.SetValue("HKEY_CURRENT_USER\\Software\\Classes\\xPlayer\\shell\\PlayWithXPlayer", "", "Play with xPlayer", RegistryValueKind.String);
Registry.SetValue("HKEY_CURRENT_USER\\Software\\Classes\\xPlayer\\shell\\PlayWithXPlayer\\command", "", "\"c:\\path to\\xplayer.exe\" \"%1\"", RegistryValueKind.String);


using System;
using Microsoft.Win32;

// substitute Registry.LocalMachine if needed...
RegistryKey rkRootKey = Registry.CurrentUser;

RegistryKey rk = rkRootKey.CreateSubKey("Software\\Classes\\.xpl");
rk.SetValue("", "xPlayer", RegistryValueKind.String);

rk = rkRootKey.CreateSubKey("Software\\Classes\\xPlayer\\shell\\PlayWithXPlayer");
rk.SetValue("", "Play with xPlayer", RegistryValueKind.String);

RegistryKey rk2 = rk.CreateSubKey("command");
rk2.SetValue("", "\"c:\\path to\\xplayer.exe\" \"%1\"", RegistryValueKind.String);


When your player app is started, it can look at its command-line parameters, and if it sees a filename passed in, it can play the file as needed.

share|improve this answer
Thanks for answering. I didn't upvote (nor downvote) because this answer is just links. Links, especially to Microsoft pages, tend to die, leading to a useless answer. If you added some examples here in the answer itself, I'd upvote it. – Chris Moschini Sep 16 '15 at 18:52
@ChrisMoschini: done. – Remy Lebeau Sep 17 '15 at 1:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.