Welcome Guest.   Make a donation to an author on the site November 27, 2014, 11:50:48 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Free DonationCoder.com Member Kit: Submit Request.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: C# question about registering file extension with particular application  (Read 2636 times)
kyrathaba
N.A.N.Y. Organizer
Honorary Member
**
Posts: 3,015



while(! dead_horse){beat}

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« on: December 24, 2006, 11:04:09 PM »

For any of you C# coders, I'm not a professional coder.  I just like to write a few programs in my spare time.  In one of these applications, I have data files written to disk by the application using Csharp's serialization.  I give these binary files an unusual (and supposedly unique) extension, namely *.crf

Now, I'll tell you what I have been able to do, and what I'd like to be able to do...

I can, of course, open one of these files from within the program, using a file-open dialogue.  Also, I can drag and drop one of these data files onto either the executable itself, or a shortcut thereof, and the program launches and opens the file.  All well and good.  What I don't know how to do (and spent many hours trying to figure out some months ago) is this:  I want to be able to right click on the data file, then click on "Open" in the popup context menu, and have the operating system recognize that it needs to launch my application to open the file.

Now... I know how to do this by manually adding a file type in Windows.  But I need to know how to create this association programmatically.  Any pointers will be most appreciated.  I've been given sample code before, but was unable to get the sample project to work, or get the code snippet to work in my own app.
Logged

Win 7 Home Premium 64bit-SP1 AMD Athlon II X2 220 Socket AM3 (938) @ 2.1GHz 6GB RAM Firefox 26.0
_________________________________________________________________________________________

I'm fighting against patent trolls. Join me and tell your representative to support the #SHIELDAct: https://eff.org/r.b6JJ /via @EFF

My DC page: http://kyrathaba.dcmembers.com | My blog: http://williambryanmiller.com/ | Proofreading Service: http://bit.ly/1fQSqQP

kyrathaba
N.A.N.Y. Organizer
Honorary Member
**
Posts: 3,015



while(! dead_horse){beat}

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: January 05, 2007, 07:22:33 PM »

Since nobody replied, I conclude that C# isn't heavily used by members of this forum Wink  I'll report on what I've discovered:  it appears that MS Visual C# Express 2005 does not offer support for creating shell support via the built-in C# installer.  I understand that the full Visual Studio version does, but that doesn't help me.  Does anyone know of any other, free, installers, that can get Windows to automatically associate an program with a particular file extension, once installation is finished?
Logged

Win 7 Home Premium 64bit-SP1 AMD Athlon II X2 220 Socket AM3 (938) @ 2.1GHz 6GB RAM Firefox 26.0
_________________________________________________________________________________________

I'm fighting against patent trolls. Join me and tell your representative to support the #SHIELDAct: https://eff.org/r.b6JJ /via @EFF

My DC page: http://kyrathaba.dcmembers.com | My blog: http://williambryanmiller.com/ | Proofreading Service: http://bit.ly/1fQSqQP

Eóin
Charter Member
***
Posts: 1,400


O'Callaghan

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: January 06, 2007, 04:07:57 AM »

Hi kyrathaba there are two very popular free installers out there: Inno Setup and Nullsoft Scriptable Install System.

Personally I use Inno, here is a sample of what a script needs to register with a file extension-
[copy or print]
...
[Tasks]
Name: associate_app; Description: {cm:AssocFileExtension,Application,.extension}; GroupDescription: Other tasks:; Flags: unchecked

...

[Registry]
Root: HKCR; Subkey: .extension; ValueType: string; ValueName: ; ValueData: Application; Flags: uninsdeletevalue; Tasks: associate_application
Root: HKCR; Subkey: Application; ValueType: string; ValueName: ; ValueData: Extension File; Flags: uninsdeletekey; Tasks: associate_application
Root: HKCR; Subkey: Application\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\Application.exe,0; Tasks: associate_application
Root: HKCR; Subkey: Halite\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\Application.exe"" ""%1"""; Tasks: associate_application

...

That script registers "Application" with ".extension" files. So you can change the word "Application" and "extension" to fit your needs. If the above is a bit confusing read the FAQ entry.
Logged

Interviewer: Is there anything you don't like?
Bjarne Stroustrup: Marketing hype as a substitute for technical argument. Thoughtless adherence to dogma. Pride in ignorance.
kyrathaba
N.A.N.Y. Organizer
Honorary Member
**
Posts: 3,015



while(! dead_horse){beat}

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: January 11, 2007, 08:01:41 AM »

Thank you VERY much Eoin.  I have Inno Setup, but have never used it.  I'll have to dig it out and play around with it.  My thanks.

- kyrathaba
Logged

Win 7 Home Premium 64bit-SP1 AMD Athlon II X2 220 Socket AM3 (938) @ 2.1GHz 6GB RAM Firefox 26.0
_________________________________________________________________________________________

I'm fighting against patent trolls. Join me and tell your representative to support the #SHIELDAct: https://eff.org/r.b6JJ /via @EFF

My DC page: http://kyrathaba.dcmembers.com | My blog: http://williambryanmiller.com/ | Proofreading Service: http://bit.ly/1fQSqQP

Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.025s | Server load: 0.12 ]