Greetings.
I've done a search regarding the above subject.
I came across this page: CreateFileAssociation

I'm on my way in developing a desktop application and I need to implement my own file format to store data in the way I want it to be. I'm quite uncertain as to how should I go about first. Anyone here has any idea? How can I benefit from the content of the above link? What do I have to know before implementing this? Thanks a lot.

Creating the association means that anytime someone double-clicks on a file with 'your' extension, your program will be launched and your WinMain will get the file name so you can open the file and do whatever you want with it.

So, if that's what you WANT, then this code is for you (and/or having your installer do it for you).

Pick an extension that no one else is using, or you'll have upset customers. In particular, there can be a large number of extensions for images, sounds, videos, and the like. So go to a 'fully loaded' machine with photoshop or its ilk on it, and then look in the registry under the file classes key and you'll see 50-100 extensions already there. Pick something ELSE.

An easy way to avoid these common other files is to pick an extension longer than 3 chars, though there may be compatability issues on non-windows OS', if that matters to you.

Thanks for your feedback.
Err, the thing that is still confusing me is that piece of code provided with the link.
Is it giving me a direction? May I know what does that piece of code do?
A wild guess, it creates a registry key and set the registry key for a new extension? Does any other application with their own extension do this everytime?

The MS File Explorer program and others like it, when coming across a file with an extension, look in the registry in a specifc location to see what program is associated with that file's extension.

This code snippet sets the registry up so that those programs can find your program. You only need to do this once at installation time.

As I say, all this does is allow someone to see your file in Explorer, double click on it, and have that run your program.

Okay. So, that means that there is nothing else that I'd have to take care on the file extension creation thing other than just setting up the registry key during installation time?

Heck give it a try and see! I haven't done this in a LONG time, so I may not have 100% of the steps down.

Okay. Thanks a lot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.