Wednesday, January 10, 2007

HowTo: Associate your c# program with a filetype

I found these couple of posts in the Microsoft forum. Take a look at them. Might be useful!

1. RizwanSharp writes:
Create an installer for your application, Right Click Setup Project in Solution Explorer, a menu will open Go to View -> File Types. In the left side a new pan will open right click on File Types on Target Machine, add a new item, Select the newly creating file type and in property window set a property for its extenssion.....

Compile and build the application and its associated.

Note: Now when you click an image it'll open up you application but that image in it, for that you have to see Main(string[] args) that what file name is coming in constructor so load that file.

2. farshad.A writes:

All the job is some registry entries:

Create an entry under HKEY_CLASSES_ROOT for the extension you wish - with the leading period (in your case, .jpg and .gif do exist).

Set a name for your filetype as the default value(jpegfile or giffile in this case, if you take a look in the windows registry).

Then create the mentioned name's key(under HKCR again), and create shell\open\command subkeys under it(that is this: HKCR\jpegfile\shell\open\command or HKCR\giffile\shell\open\command).

Set as default value your executable's path and the command-line argument to pass to it, which would be simply %1 if you want the filename to pass to your program: "c:\myapp.exe" %1

No comments: