Page 1 of 1

how do you associate files

Posted: Thu Aug 28, 2008 3:14 am
by juliusctw
hello I write this little interpreter that reads a script and executes it, right now you would do something like ,

linux
./myProg filePath

windows
myProg.exe filePath


and it would read the file in an execute it, but I would like to be able to just click on the file on the desktop (in both windows and linux) and have the program run, (like how python works) , i'm pretty sure in windows I would need to play around with the registry , but i'm not sure how to do it in linux .

people suggested to use #! , but I would really like to avoid that , I want it to just look at the extension and execute accordingly, any suggestions?
as for windows, I am also not very confident with the registry, are there any tools that could just make it easier? or any tutorials I can read ? thank you very much

Posted: Thu Aug 28, 2008 6:21 am
by Azgur
In windows it's pretty easy if you use a file extension that hasn't been registered yet.
Just try to open the file by double clicking it, windows will complain a bit about unknown extension etc, tell it you will select the application from a list, hit browse, navigate to your exe, hit ok a few times and you're done.

thanks

Posted: Thu Aug 28, 2008 6:53 am
by juliusctw
hello
thanks for that suggestion, but I meant how to do it using only c++ , i kinda have an idea how to do it in windows, but i'mt not sure what the best way for linux is that would work on kde , gnome, and all distributions

Posted: Thu Aug 28, 2008 7:43 am
by syedhs
Azgur wrote:In windows it's pretty easy if you use a file extension that hasn't been registered yet.
To change for already registered extensions, simply hold down Shift key while right clicking on the file. You will find 'Open With' in the menu which sometimes appear or doesn't without holding the Shift key.

To the original question, maybe you can simply use 'shell'? Or in windows, use ShellExecute on the file will always launch the associated application.

Actually I am not very clear about your question because your original and subsequent questions are quite contradicting.