Cool_Coder
Cool_Coder

Reputation: 5073

Create Associativity between file extension & application?

I am creating an application using Qt. The files saved from my application have their own file format & extension. I want to associate this file format with my application. So, when a user double clicks say myfile.ext then the OS should automatically run my application (how to specify its path?) & pass path of file as an argument.

I have only used Windows until now so I am talking in terms of it. I dont know how other OS's behave. Any guidance for the same would be helpful?

PS: Even though I am using Qt which apparently has no special functionality to do what is asked here (AFAIK), it would be awesome to know how to do this in standard C++.

Upvotes: 0

Views: 112

Answers (2)

Frerich Raabe
Frerich Raabe

Reputation: 94319

For Windows see the MSDN page "File Type Handlers" for how to register file type handlers.

On many popular Linux desktops, so-called .desktop files are used to define what application to use for opening a file. See the "Desktop Entry Specification" for the structure of those .desktop files. They are quite simple really, changes are you can just take an existing file from any of the popular Linux desktop environments (e.g. KDE) and modify it a bit.

Upvotes: 2

John3136
John3136

Reputation: 29266

It's a function of the OS, not of the C++ language. You'll need to figure it out on each platform you are supporting.

Upvotes: 1

Related Questions