Open With in windows and linux

Started by tlf30, January 14, 2012, 00:51:33

Previous topic - Next topic

tlf30

I'm trying to build a program that will open a custom file format. I was wondering if there was a way to open the file with the program like how you can open a .txt by clicking open on the file in windows and linux.

CodeBunny

I'm not sure how to do it, but I'd recommend switching to a custom file extension. If you give a user the program and they install it, they might get pissed that they see the option for every single text file.

tlf30

The txt was an example, im using akfw and akfa.

Fool Running

On windows, it requires writing values to the registry (HKEY_CLASSES_ROOT has the information). I'm not sure about Linux, but it is probably a file somewhere.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

tlf30

Thank, but how does the program know what file you are running it from.

Fool Running

The file name is passed on the command-line. For instance, in Windows, you specify the command to run when opening a file (located in the registry).
This is an example using my mapping for a Visual Studio .sln file. It will run:
"C:\Program Files\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe" "%1"

The '%1' gets replaced with the file that the user opened.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

tlf30