how do you associate files

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
juliusctw
Gremlin
Posts: 159
Joined: Thu Sep 28, 2006 8:15 pm

how do you associate files

Post 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
User avatar
Azgur
Goblin
Posts: 264
Joined: Thu Aug 21, 2008 4:48 pm

Post 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.
juliusctw
Gremlin
Posts: 159
Joined: Thu Sep 28, 2006 8:15 pm

thanks

Post 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
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Post 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.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
Post Reply