Visual C# Associating file types with programs  
Author Message
Damion Chambers





PostPosted: Visual C# General, Visual C# Associating file types with programs Top

I would like to create an application that works similar to microsoft word or the other ms office suite applications. i.e. I would like to create and install my program so it can

1. Associate files i create with a particular extension to my program.
2. when i click on files with my extension they launch my program and open the data similar to a ms word document.

Iif anyone may be knowledge of this or knows what the technical name for this time of programming is called i would sincerely be grateful.

 or reply to this post.

 




Visual C#4  
 
 
Paul Louth





PostPosted: Visual C# General, Visual C# Associating file types with programs Top

You may use Microsoft.Win32.RegistryKey class to modify the registy to do
this.


string keyName;
string keyValue;
//This creates a Root entry called "MyApp".
keyName = "MyApp";
keyValue = "My Application";

RegisterKey key;
key = Registry.ClassesRoot.CreateSubKey(keyName);
key.SetValue("",keyValue);
key = key.CreateSubKey("shell");
key = key.CreateSubKey("open");
key = key.CreateSubKey("command");
key.SetValue("","c:\\temp\\my.exe %1");

keyName = ".bar";
keyValue = "MyApp";
key = Registry.ClassesRoot.CreateSubKey(keyName);
key.SetValue("", keyValue);

http://www.dotnet247.com/247reference/msgs/21/109542.aspx


 
 
Damion Chambers





PostPosted: Visual C# General, Visual C# Associating file types with programs Top

Hi Paul,

Thanks for responding. I check out the codes and confirm that it creates the registry entry. But I would rather all this be done at installation. Can the dotnet installer do create these registry entries automatically I have heard that installshield might be able to do it. If so part 1 of my problem would have been solved. Part 2 would now be to find the code that would load my file. i.e. pick up the file name and location that triggered the program to run.

If you have anything on the above let me know. Thanks.



 
 
Damion Chambers





PostPosted: Visual C# General, Visual C# Associating file types with programs Top

Hey Paul,

Thanks for the info. Do you also know how I can change the file icons to show the icon my program uses